How to split decimal to alert(
cm = 14*2.55;
outputCMVal = Math.round(cm*10)/10;
alert(outputCMVal); //35.7
arrDecimal = outputCMVal.split('.');
alert(arrDecimal[1]); //want to alert 7 from outputCMVal
How to split decimal to alert(
cm = 14*2.55;
outputCMVal = Math.round(cm*10)/10;
alert(outputCMVal); //35.7
arrDecimal = outputCMVal.split('.');
alert(arrDecimal[1]); //want to alert 7 from outputCMVal
split() Method is a member of string. Since outputCMVal
is a number, you need to call .toString()
method before .split('.')
arrDecimal = outputCMVal.toString().split('.');
Concatenate it to String before splitting by Character .
var cm = 14*2.55;
var outputCMVal = Math.round(cm*10)/10;
alert(outputCMVal); // 35.7
var arrDecimal = (outputCMVal+"").split('.');
alert(arrDecimal[1]); // 7
also assign your var