Interger to String.

admin

Administrator
Staff member
Hi, I am a newbie to JavaScript, I have serious problems with converting integer to string.

I have interger which I want in zeros before format (Eg. 001 for 1)

I am using the following function for this, but I am getting errors, myinteger undefined.

function setZ(num){
var myinteger=num;
var mystring=myinterger + '';
var mystr;
if(num<=9) {
mystr='00'+ mystring;
}else{
if(num<=99){
mystr='0'+mystring;
} else {
mystr=mystring;
}}
return mystr;
}


Also can anyone tell me the syntax for CASE statment in JavaScript?

Help.
 
Back
Top