How to convert array of strings to array of numbers in Node.js

1 Answer

0 votes
const arr = [ '999', '12', '87', '99', '4' ]

const arrOfNumers = arr.map(element => { return Number(element); });

console.log(arrOfNumers); 

console.log(typeof arrOfNumers[0]); 

  
  
  
  
/*
run:
  
[ 999, 12, 87, 99, 4 ]
number
  
*/

 



answered Jun 21, 2022 by avibootz

Related questions

1 answer 122 views
1 answer 112 views
1 answer 147 views
1 answer 124 views
124 views asked Aug 27, 2022 by avibootz
...