String Length Limiter

I am trying to make a stats app where it tracks total number of kills, deaths, and also tracks average kills and average deaths. The thing is, when there is a repeating decimal outputted by the calculator, it tries to display the whole thing. How do you limit how many decimal places it shows?

If you want to display 2 decimal places, multiply the number by 100, use Math.round to round to nearest integer. Then divide the result by 100.

You can also use the .toFixed() function:

Number.toFixed(2)