问题
码
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));
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
运行结果
