0

I want to trim my 5 or more than 5 digit number 12345 to

12.34k

to fit it in my small box. Is there any util to use?

Cecilia Chan
  • 679
  • 2
  • 8
  • 17

1 Answers1

0

you can divide it by 1000 and then specify the number of digits you want using toFixed()

let x = 12345;
x = x/1000;
x = x.toFixed(2);
x = x + "k";

console.log(x)
marvel308
  • 10,288
  • 1
  • 21
  • 32