题目描述:多位数字从后往前每隔3位加一个逗号
例:
输入:12345678
输出:12,345,678
function addComma(num) {
var str = num.toString(),
res = ''
while(str.length > 3) {
res += ',' + str.slice(-3) + res
str = str.slice(0, str.length - 3)
}
if(str)
res = str + res
return res
}