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.
Any time you find yourself writing code like "if(x){return true} else{return false}", you can simply replace it with "return x", since x will resolve to true or false anyway. In your example the logic is reversed, but still it's basically saying "if(true){return false} else {return true}", so you could replace that with "return !x"
yes
Kata stipulates "an array with exactly 5 strings". Not great for general use, but meets the requirements of the kata.
It isn't one loop. It filters (and sorts) twice. EDIT: nevermind, I see that you're asking how one might do it in one loop.
I gotta admit, this is highly readable!
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'm afraid I don't know the under-the-hood aspects of sort as well as I'd like, but it does seem to sort numbers by default.
I also realized that it should probably be i <= 100, just for the outlier situation of having 10 arrays of 10 elements covering numbers 0-99
Nice solution! My only question is how the .sort() function is successfully sorting numerically (rather than its default - alphabetically) without a function passed to it?
This comment is hidden because it contains spoiler information about the solution
What's the point of slicing? It seems to be extra overhead and less readable.
WOW
first
use === instead of ==
But then you'd have to type all those quotes and commas!!
Loading more items...