Skip to content

Instantly share code, notes, and snippets.

@henryspivey
Forked from prof3ssorSt3v3/11-map.js
Last active October 30, 2019 21:28
Show Gist options
  • Select an option

  • Save henryspivey/f9993c95197e88cc916d2a0d651c6f4c to your computer and use it in GitHub Desktop.

Select an option

Save henryspivey/f9993c95197e88cc916d2a0d651c6f4c to your computer and use it in GitHub Desktop.
//Why do we get this weird result from the map method?
// myarray.map(func);
//We want to convert 3 strings into numbers
let result = ['1', '7', '11'].map(parseInt); //returns [1, NaN, 3]
// solution
['1', '7', '11'].map(item => parseInt(item))
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment