Ad
  • Custom User Avatar

    Clever use of for! This has to be the most efficient solution (except for using a global variable)

  • Custom User Avatar

    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 a const 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.

  • Custom User Avatar

    Why would you do this as opposed to v*v? Seems like crossing the river for water, or is there any benefits? :)

  • Default User Avatar

    It's the same number of characters either way.

  • Custom User Avatar