javascript - Truncate number to two decimal places without rounding - Stack Overflow

PHOTO EMBED

Wed Nov 24 2021 13:09:40 GMT+0000 (Coordinated Universal Time)

Saved by @Sipho

num = num.toString(); //If it's not already a String
num = num.slice(0, (num.indexOf("."))+3); //With 3 exposing the hundredths place
Number(num); //If you need it back as a Number
content_copyCOPY

https://stackoverflow.com/questions/4187146/truncate-number-to-two-decimal-places-without-rounding