Skip to content

Instantly share code, notes, and snippets.

View MarvinXu's full-sized avatar

Marvin MarvinXu

  • 16:40 (UTC +08:00)
View GitHub Profile
@MarvinXu
MarvinXu / commfy0.js
Last active August 29, 2015 14:06 — forked from hotoo/commfy0.js
function commfy0(n){
var a = n.toString().split(".");
var i = a[0].length%3;
var prefix = (a[0].substr(0,i)+a[0].substr(i).replace(/(\d{3})/g,",$1")).replace(/^,/, "");
//var postfix = a[1] ? "."+a[1].replace(/(\d{3})/g, "$1,").replace(/,$/, "") : "";
return prefix+(a[1]?"."+a[1]:"");
}