Ad
  • Custom User Avatar

    Good Question, i have no clue anymore.
    I guess it was at the time i wanted to learn a bit more about Linq
    and tried to solve a lot with usage of Linq

  • Custom User Avatar

    Guess they just copied the 'best practice'

  • Custom User Avatar

    Modified the starting code to be more beginner-friendly and less repulsive.

  • Default User Avatar

    I think using properties of the object (result-array) is much more obvious and understandable by other developers. There is no risk of changes of the length after creating the array (and if it would change you wouldn't have the threat of missing it), where 'n' could be used for something else in between the array creation and the population of the array.

  • Custom User Avatar

    Or more generally, for any object that has length property.

  • Default User Avatar

    As for mappability, it depends on what you consider mappable. Array.prototype.map works on strings.

  • Default User Avatar

    Functional tools like map are very standard now and should be familiar to anyone using the language seriously. The only part of this answer that is tricky is the use of split(''), but this is a pretty common trick for getting an array of characters (as Javascript unfortunately won't treat strings as mappable collections). join is used in a plain way. The implicit conversions from string to int are a little weird.