JavaScript Code


How to convert number to string in JavaScript?


Convert number to string

Given a number, convert the number to a string, using JavaScript.

Solution

To convert given number n to a string using JavaScript, call toString() method on the number.

n.toString()

Programs

1. Given a number n. Convert the number to string.

var n = 5421;
var str = n.toString();
console.log(str);