xsheetjs/packages/ssf/bits/56_commaify.js

8 lines
215 B
JavaScript
Raw Normal View History

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