Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

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: 2020-10-01T13:38:04+05:30

549 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements