The Math library is a collection of functions and constants that are useful for doing calculations.
They can be familiar numbers, like Math.PI, which will give you the number 3.14159… or operations like sine and cosine, which you can do with Math.sin and Math.cos.
The Math library also has many different ways you can round a number:
- Math.floor, used in the last step, always rounds down.
- Math.ceil always rounds up.
- Math.round will round to the nearest whole number, either up or down.
- There are a couple of other less common options, like Math.fround and Math.trunc
You can also do exponents with Math.pow, or take a square root with Math.sqrt!