In JavaScript, you can use the toString() method to convert an integer to a string.

Example:

let num = 42;
let str = num.toString();
console.log(str); // "42"

You can also use the String() function or the unary plus operator to convert an integer to a string.

let num = 42;
let str1 = String(num);
let str2 = "" + num;
console.log(str1); // "42"
console.log(str2); // "42"

You could also use the JSON.stringify function to convert an integer to a string.

let num = 42;
let str = JSON.stringify(num);
console.log(str); // "42"

Keep in mind that all these methods will convert the integer to a string but the JSON.stringify() will also add double quotes around the string, if you don’t want that you can use the toString() or String() method.

Also Read:

Categorized in: