Convert integer array to string array in JavaScript?


To convert integer array to string array, use the map(String) in JavaScript. Let’s say the following is our integer array −

var integerValues = [101,50,70,90,110,90,94,68];

Convert integer array to string array −

integerValues.map(String);

Example

Following is the code −

var integerValues = [101,50,70,90,110,90,94,68];
console.log("The integer array value=");
console.log(integerValues);
integerValues.map(String);
console.log("The string array value=");
console.log(integerValues)

To run the above program, you need to use the following command −

node fileName.js.

Here, my file name is demo212.js.

Output

The output is as follows in console −

PS C:\Users\Amit\JavaScript-code> node demo212.js
The integer array value=
[
   101, 50, 70, 90,
   110, 90, 94, 68
]
The string array value=
[
   101, 50, 70, 90,
   110, 90, 94, 68
]

Updated on: 01-Oct-2020

403 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements