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

1 Answer

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

const arrOfStrings = arr.map(num => { return String(num); });

console.log(arrOfStrings); 

console.log(typeof arrOfStrings[0]); 


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

 



answered Jun 21, 2022 by avibootz
...