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.
Damn...i forgot about for...of operator. Used classic for
This mutates arr outside the function ( not just the output but the original reference too! )
You can avoid this with by first duplicating arr ( with something like array.slice() )
FYI this won't work in strict mode without let [a,b]. See my fork.
Wow, a pithy solution !
I think the same can be done like this:
return root%1 ? -1 : Math.pow(++root, 2);
since root%1 would return a non zero value (i.e. it's remainder) if it not completely divisible.