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.
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!!
Oh I'm dumb. I forgot that
methods
only refer to functions, not variables.I'm curious as a beginner if your approach, which seems to ignore the intent (as the given code includes concatenation), is based on industry best practices, or simply to stick it to kata creators who write ambiguous instructions (or are these one in the same?)? Either way, it's fun to see solutions that think outside the box.
Loading more items...