Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by Steven Ryssaert for Round the value in Javascript

This actually is trickier than it first seems. Removing leading zero's is not something that is standard Javascript. I found this elegant solution online and edited it a bit.

function removeLeadingZeros(strNumber){  while (strNumber.substr(0,1) == '0'&& strNumber.length>1)  {    strNumber = strNumber.substr(1);  }  return strNumber;}userInput = "000.03";alert(removeLeadingZeros(userInput));

Viewing all articles
Browse latest Browse all 7

Trending Articles