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.
This is because first two items are checked before the for loop
Why do you return the string instead of
false
?That's because of JS's limitation on amount of arguments you can pass to a function though.
Also, there are no performance requirements here, so I'd go for the shorter (and cleaner) code ;-)
HI can you tell me how to use this website
You didn't understand how to sort it, or how the sort method works.
See the example again:
Your code returns
[ 9, 8, 7, 5, 4, 3 ]
Reversing is not the same as sort in descending order.
Consider a string like
")))((("
. It would returntrue
in your function, but that is obviously an invalid input.