|
|
|
|
|
by contextnavidad
1222 days ago
|
|
It passes the value and index to `parseInt`, where the 2nd argument is `base`. So it does not return `[10, 10, 10]` as you'd expect. It returns `[10, NaN, 2]` instead. You have to do `['10', '10', '10'].map((val) => parseInt(val, 10));` to get the "expected" output. In addition, you should always provide `base` to `parseInt` otherwise it has it's own interpretation infered by the value you give it. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... |
|
Also the parens around a single argument of an arrow function are a superstitious thing suggested by some well-known react developer a while back, I think.