I am needing to truncate the number of decimals in a floating point number to a specific number and discarding the rest, at the moment the only method I found is toFixed
but this rounds the value not truncates:
let num = 21.777777;
console.log(num.toFixed(1));
console.log(num.toFixed(2));
console.log(num.toFixed(3));
console.log(num.toFixed(4));
It happened to someone else, how did you solve it, I was thinking of converting to a string and trimming the string, but I want to know if there is a way to do it without resorting to that.