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.
Clever use of for! This has to be the most efficient solution (except for using a global variable)
Hello, the array is generated with the Javascript code
a=[];for(i=0;i<10;i++)a[i]=i**2;a.join(',')
. However,**2
is ES6 and not a very portable solution, and pre-generating the array into aconst
will make it less readable. This decision to pre-feed corresponding solutions into a lookup table is a balance between intuitiveness and simplicity, where for coding challenges, keeping the solution efficient and simple often makes the intention come to light better.Also, since the number of digits doesn't change as we're always using denary (base 10), there's no real advantage to keeping it dynamic, other than being modular.
Why would you do this as opposed to v*v? Seems like crossing the river for water, or is there any benefits? :)
It's the same number of characters either way.
Very elegant!