题解 | #分隔符#
分隔符
http://www.nowcoder.com/practice/e5696992841841a8ab9d026324e4bb77
if(number < 0) {
negative = '-'
number = Math.abs(number);
}
number=number.toString();
let sign = 0
let sum =""
for(let i=number.length-1 ; i>=0 ; i--) {
if(sign === 3) {
sum+=","
sign = 0
}
sum+=number[i]
sign ++
}
return negative+sum.split("").reverse().join("")