View Full Version : Changing Variables

04-18-2005, 09:10 PM
Is there a certain way to go about to changing a number into a string? I'm trying to make this number change into a string so I can then search the string and add to a different stuff because of what's inside of the first string. Can anybody help me?

04-18-2005, 09:35 PM
You can use the toString method.

k = 25;
x = k.toString();


04-19-2005, 05:53 AM
If you will append the number into a string, you don't need to convert the number into a string because it is automatically converted to string.

var s = "blah"
var s2 = s + 1; //blah1

04-19-2005, 09:25 AM
Back when I was still learning JavaScript (I still am sometimes, but hey) I didn't use ToString - I just added an empty string to the integer, like this:

var a = 1
a = "" + 1

Ah, the good old days of newbie coding. But it worked! :p