How to convert array of strings to array of numbers in JavaScript

1 Answer

0 votes
const arr = ["5", "7", "18", "389"];

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

console.log(arrOfNumers); 

console.log(typeof arrOfNumers[0]); 


  
  
  
  
/*
run:
  
[5, 7, 18, 389]
"number"
  
*/

 



answered Jun 21, 2022 by avibootz
...