Convert a string array to an int array in Javascript
To convert an array of strings to an array of numbers:
Use the
forEach()
method to iterate over the strings array. On each iteration convert the string to a number and push it to the numbers array.js string array convert to int
let arrayOfNumbers = arrayOfStrings.map(Number);
js how to convert all string in array into integer
array = ['1','2','3']
arrayInt = array.map(Number)
Output
arrayInt = [1,2,3]