Js arithmetic toFixed() method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Js arithmetic toFixed() method

suppose: var total = 50; var quantity = 2; var fixedPrice = total/quantity; console.log(fixedPrice.toFixed()) should be 25, since there is no int argument passed onto toFixed() method, to specify decimal digit precision after the integer fraction.

22nd Apr 2024, 3:39 AM
Oliver Pasaribu
1 Answer
+ 1
Yes. When you don't specify any argument for the toFixed() method, it defaults to 0, which means it will round the number to the nearest integer.
22nd Apr 2024, 4:20 AM
`нттp⁴⁰⁶
`нттp⁴⁰⁶ - avatar