+ 2
when we getting square root of 2 I use toFixed(3) but in this way sqrt(25)=5.000 /remove extra zeros. suggest improvements....
3 odpowiedzi
+ 2
A trick I like is to use parseFloat/Number/+ in combination with toFixed:
parseFloat(Math.sqrt(i).toFixed(3))
OR,
Number(Math.sqrt(i).toFixed(3))
OR,
+(Math.sqrt(i).toFixed(3))
+ 1
thanks it works
+ 1
Glad I could help 😊