-->

1000 to 1k, 1000000 to 1m etc. number abbreviation

2019-09-22 09:16发布

问题:

How can I have 1000 convert to 1k or 1200 to 1.2k? There's other solution for other programming language but I can't figure out how to make it work with AS3.

Or is there a shorter way to do it rather then if number > 1000 then make it 1k?

回答1:

Couldn't you just do something like this

var numInK = bigNumber/1000 + "k";

Maybe you could throw in a Math.round or some other checks to avoid ridiculous numbers like 3.3333333K