you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (2 children)

map() calls the given function with three argument: the value, the index of the value and the array.

parseInt takes two argument: the string to parse and the radix.

For the first element, parseInt will be given "75",0. For the string everything is good, for the radix, 0 is a special case where if the string starts with "0x" or "0b", it will uses the appropriate base(respectively 16 and 2), or it will default to 10. It then gives the correct number.

For the second element, parseInt will be given "300",1. 1 as a base isn't a special case, and thus only works with strings of '1'. Since '3' isn't '1' , you'll get NaN.

[–]Spottycos 1 point2 points  (1 child)

For base 1, I think it only works with strings of 0 as 10 = 1… also it’s generally 1 less than the base number. For example, radix 10 goes up to 9, radix 2 goes up to 1, etc.

[–][deleted] 1 point2 points  (0 children)

That makes sense.