# String Length Limiter

**URL:** <https://forum.code.org/t/string-length-limiter/36967>\
**Category:** Uncategorized\
**Created:** [September 27, 2022, 3:59am UTC](https://forum.code.org/t/string-length-limiter/36967 "2022-09-27T03:59:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiden1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@aiden1](https://forum.code.org/u/aiden1)\
**Post date:** [September 27, 2022, 3:59am UTC](https://forum.code.org/t/string-length-limiter/36967/1 "2022-09-27T03:59:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)\
**Post date:** [September 27, 2022, 4:16am UTC](https://forum.code.org/t/string-length-limiter/36967/2 "2022-09-27T04:16:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wutadam](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/wutadam/32/7711_2.png) [@wutadam](https://forum.code.org/u/wutadam)\
**Post date:** [September 27, 2022, 12:10pm UTC](https://forum.code.org/t/string-length-limiter/36967/4 "2022-09-27T12:10:44Z")

</div>

You can also use the `.toFixed()` function:

```javascript
Number.toFixed(2)

```
