How to round a number in JavaScript?

Sometimes, we want to round a number in JavaScript.

In this article, we’ll look at how to round a number in JavaScript.

How to round a number in JavaScript?

To round a number in JavaScript, we use the Math.round method.

For instance, we write

const rounded = Math.round(332.24);

to call Math,round with the number we want to round.

It returns the rounded number as an integer.

Conclusion

To round a number in JavaScript, we use the Math.round method.