-
Need help in moving the comma
Hi, I came across this incredible number counter, I need help in moving the comma one place left. For example, currently, it’s like this 400,00. I want it to be 40,000.
numDecimals = 0;
commas = true;
dollarSign = false;
beginCount = 500;
endCount = 40000;
dur = 2;
t = time - inPoint;
s = ease (t, 0, dur, beginCount, endCount).toFixed(numDecimals) + "+";
prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += "$";
if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
outStr = s.substr(-s.length, (s.length-1)%3 +1);
for (i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s;
}