题解 | #分隔符#
分隔符
https://www.nowcoder.com/practice/e5696992841841a8ab9d026324e4bb77
function _comma(number) { const toStr = number < 0 ? (number * -1) + '' : number + ''; console.log(toStr); let array = Array.from(toStr); let count = 0; for (let i = array.length - 1; i > 0; i--) { count++; if (count === 3) { array[i - 1] += ','; count = 0; } } return number > 0 ? array.join('') : '-' + array.join(''); }
数学差生解法