sheetjs-clone/bits/56_commaify.js

7 lines
203 B
JavaScript
Raw Normal View History

2017-03-21 07:45:12 +00:00
function commaify(s/*:string*/)/*:string*/ {
if(s.length <= 3) return s;
var j = (s.length % 3), o = s.substr(0,j);
for(; j!=s.length; j+=3) o+=(o.length > 0 ? "," : "") + s.substr(j,3);
return o;
}