问题
码
const numberTokw = num => {
if (num < 1000) return num
let endStr = 'w',
numVal = 10000;
if (num > 999 && num < 10000) {
endStr = 'k'
numVal = 1000;
}
let zhen = parseInt(num / numVal),
yu = num % numVal;
if (yu === 0) return zhen + endStr
yu = String(yu).slice(0, 1)
return zhen + '.' + yu + endStr
}
console.log(numberTokw(1000));
console.log(numberTokw(1100));
console.log(numberTokw(7000));
console.log(numberTokw(2363));
console.log(numberTokw(9999));
console.log(numberTokw(10000));
console.log(numberTokw(13400));
console.log(numberTokw(99999));
运行结果