Conversation
| module.exports = function(numbers) {}; | ||
| module.exports = function(numbers) { | ||
| return numbers.map((number)=> number +1) | ||
| }; |
| var getWordLengths = function(someWords) {}; | ||
| var getWordLengths = function (someWords) { | ||
| return someWords.map(word => word.length) | ||
| }; |
| return numbers.reduce(function (a, b) { | ||
| return a + b; | ||
| }, 0); | ||
| } |
| @@ -1,3 +1,10 @@ | |||
| function findNeedle(words) {} | |||
| function findNeedle(words) { | |||
| let result; | |||
There was a problem hiding this comment.
if you look at the test, you have two arguments passed, expecting two parameters.
| function factorial(int) {} | ||
| function factorial(int) { | ||
| // let result = 1, i = int; | ||
| if (int === 0 || int === 1) |
There was a problem hiding this comment.
while int is not reserved anymore in JS 5, it is reserved word in previous versions afaik
it's also reserved in many other languages. so while parameter is coming as int, it can be useful to save it in another variable
There was a problem hiding this comment.
Also this will save you the trouble of the first conditions, as you can initialize it with 1
| let maxIndex = array.indexOf(actualMax) | ||
| array.splice(maxIndex, 1) | ||
| return Math.max(...array) | ||
| } |
There was a problem hiding this comment.
nice work, and works fine
the only a couple of issues, the complexity is high here
You needed to loop through the array twice to get the max
also what if max number is duplicated ?
| numArray.push(element) | ||
| } | ||
| }); | ||
| let sum = numArray.reduce(function (a, b) { |
There was a problem hiding this comment.
Also nicely done
you can make it fast using one loop also to do both checking if it's number and adding it
| result["Land Rover"] = rover | ||
| result.Toyota = toyota | ||
|
|
||
| return result |
There was a problem hiding this comment.
Really good work
you can add more test to make it fail
and move from hard-coding the car modules to program them in
| @@ -0,0 +1,7 @@ | |||
| function paintCars(array, color) { | |||
| // I didn't understand what is required to be done so I hardcoded the index | |||
There was a problem hiding this comment.
this is a tricky one
they expect you to change the color of the Ford model (or first car) to the color they choose
There was a problem hiding this comment.
remember it should not change the original object colour
if you stuck let me know for more hints
| @@ -0,0 +1,4 @@ | |||
| function cities(array, func) { | |||
| return array.map(item => func(item)) | |||
There was a problem hiding this comment.
correct
also when writing map, you don't need to create it as array function if you're passign a function
something like
array.map(func)
| }); | ||
|
|
||
| return greeting; | ||
| return myarray; |
There was a problem hiding this comment.
nice work, while forEach is pushing to another array (not quite its role)
something like map will help you better
| const result = greetPeople(mentors) | ||
|
|
||
| // Assert | ||
| expect(result).toEqual(expected) |
| } else { | ||
| result.push("_"); | ||
| result.push(character); | ||
| } |
There was a problem hiding this comment.
The idea for those tests, is to add more tests to make your functions work better. So try to do that and we can review them later on
I missed one of the tests in my last PR, so here I'm submitting them again to get feedback on them.
Thanks.