Conversation
illicitonion
left a comment
There was a problem hiding this comment.
Well done, this is a really good effort :) I left a few comments with some things to fix up, but this is some really good progress!
| let isHappy = true; | ||
|
|
||
| if (isHappy) { | ||
| if (!isHappy) { |
There was a problem hiding this comment.
While this change makes the test pass, reading the code, it doesn't really make much sense. If isHappy is true, we'll return I am not happy which doesn't sound right...
I realise this is a weird and very contrived exercise, but is there another change you could make which would mean that this function made a bit more sense?
|
|
||
| function remove(arr, index) { | ||
| return; // complete this statement | ||
| arr.splice(index, 1); |
There was a problem hiding this comment.
This works except that one of the requirements of this function is that it doesn't change the original array - splice changes the original array. Can you give this another go making sure not to change the original array?
|
|
||
| let newArr = []; | ||
| for (let i = 0; i < arr.length; i++) { | ||
| arr[i] = arr[i]; |
| function formatPercentage(arr) { | ||
|
|
||
| let newArr = []; | ||
| for (let i = 0; i < arr.length; i++) { |
There was a problem hiding this comment.
This function returns the right thing, but it will change the values in the input array too - can you change the function so that it won't change the input array?
| return arr; | ||
| } | ||
|
|
||
| function sortAges(arr) { |
There was a problem hiding this comment.
Very impressive! Well done!
| console.log(e); 9, 13 | ||
| 4. How many times is "f1" called? // 1st call of f1 is when consol.log(e) = 9, // last time f1 is called and resulting in console.log(e) = 13 | ||
| 5. How many times is "f2" called? // 1st call of f2 is when console.log(d) = 4, second time f2 is called and resulting in console.log(d) = 6 // last time f2 is called and resulting in console.log(d) = 8 | ||
| 6. What value does the "a" parameter take in the first "f1" call? // value 8 |
There was a problem hiding this comment.
This is actually the answer to question 7 :) This is asking what value the a parameter on line 21 will have, not what the a variable on line 19 will have. Can you try this one again?
Your Details
Your Name: Harris Sheraz
Your City: London
Your Slack Name: Harris Sheraz
Homework Details
Module: JavaScript-1
Week: 2