0
我有一個格式化函數貨幣:ESLint錯誤:中意外分配的 '而' 語句
export const formatDollar = (dollar) => {
const format = function moneyFormat(val, sign = '$ ') {
const pieces = parseFloat(val).toFixed(2).split('');
let ii = pieces.length - 3;
while ((ii -= 3) > 0) {
pieces.splice(ii, 0, ',');
}
return sign + pieces.join('');
};
return format(dollar);
};
這部分引起ESLint錯誤:
while ((ii -= 3) > 0) { pieces.splice(ii, 0, ','); }
error Unexpected assignment within a 'while' statement no-cond-assign
如何我應該寫這個聲明,以便ESLint檢查通過嗎?