Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Waowww! it is good solving ! :)
Да, интересно в чем проблема
wtf
Тесты это решение не проходит, но attempt прошел успешно
ow,its good!
'filter' creates a new array + iterates through the total array.
the 'reduce' solution stops when needed and returns a boolean.
Right. I was working directly with base array. Now it's ok. Thanks for clarification.
Confirm. Seems like something wrong with random test function for js. Test output:
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I found you can use
console.dir()
on your result for this case or just test your function in browser's console.Great, thanks!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Note that if user for some reason defines an empty string as the "name" attribute this approach (name || 'Hero') prevents him to do that. In the kata description we read "user argument or 'Hero'" ("argument", not "name"). So in fact empty string is legal.
In my opinion it's better to use default function parameters (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters)
or checking for 'undefined'.