Every time I do something like + 1.6 or something that's a decimal, I get a lot of random numbers spammed behind the result. how to avoid?
Asked
Active
Viewed 33 times
-2
-
could you please provide more information? such as what's the calculation you are trying to perform, what is your expected result and what's the actual result you're getting – Liad Aug 12 '21 at 21:47
-
round the result to desired precision? – Yevhen Horbunkov Aug 12 '21 at 21:50
1 Answers
-2
var test = 1.2345; console.log(test.toFixed(2))
// It will trim the result to the specified decimal places. // |----> output will be 1.23 in thid case... It will keep upto 2 decimal places

Rishabh Jain
- 32
- 1