Forum Discussion

darshthakkar's avatar
darshthakkar
Valued Contributor
3 years ago
Solved

Can we round integers to 2 digits?

Hi Team, I was using the Math.round() but was wondering if we can decide on the decimal digits for the rounding. For example, number = 3.14125252 Desired output = 3.14 With Math.round(), outp...
  • darshthakkar's avatar
    3 years ago

    Thank you @Soni37 for the insights.
    I had to convert my string to a number and then apply this formula. I was also able to learn more about .toPrecision()

    Link to the documentation

    Thank you again.