1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
export function formatNum(str) { var newStr = ""; var count = 0; for (var i = str.length - 1; i >= 0; i--) { if (count % 3 == 0 && count != 0) { newStr = str.charAt(i) + "," + newStr; } else { newStr = str.charAt(i) + newStr; } count++; } str = newStr; return str; }