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?
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?
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)