Okay this is very off-topic, but why is it that passing (value, key) instead of just (key) allows you to successfully populate the array?
I'm not sure whether your edit means you figured it out, or that you're still confused but your examples are backwards
😉
Per the documentation of some(), the second argument is a map function called on each element:
The Array.from() method returns an array from any object with a length property.
www.w3schools.com
Similarly, per the documentation of map(), the first argument is simply the current value of the given element:
Return a new array with the square root of all element values.
www.w3schools.com
If you simply call Array(101), each of those 101 elements are undefined. So only passing one argument into the map function will reference their current value, produce
undefined + 1 and all math in JavaScript with undefined produces NaN.
The
second argument of map(), however, is the current index of the given element, and that must be a value. So you can perform math on the index (what Trihan labeled key) to produce a value for the elements of the array.
In your example where you actually initialized the values of the array elements manually (
[0, 1, 2, 3, etc.] ) only passing the first argument into map() has a defined value to work with. But in that case the whole thing is kind of pointless because what Trihan provided was a shorthand to initialize the values of a large array
without typing it out.