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.
There's a way to make it one line tho :)
One line solutions are usually not the best ones (in terms of performance and readability) but people still upvote them because they look cool
That's true. But then I'd have to do
-1
in 3 places. And my two<
would become<=
.Nice solution, could start your iterators at 1 to avoid the + 1
Assigning is slightly faster than pushing (~20%). Either way is fine though.
What's better? doing push() or assign a value to a nonexistent element of the array?
Being a new JS Programmer, I was becoming disillusioned with every "easy" Kata top solution being one line of Regex.
I'm happy to finally see something very close to my answer as Best Practice.