“The universe is regulated by Math formulas” my grumpy teacher used to say. And the galaxy of coding isn’t escaping from that rule any time soon — as I was hoping. Luckily for us, a language like JavaScript gives us tools like the Math object to deal with numbers and their operations.
When it comes to rounding numbers, Math helps you with three main functions: Math.ceil
, Math.floor
and Math.round
.
This method rounds up the only passed in value to the nearest greater integer. I find the word ceil meaningful in this case, as it reminds to a ceiling, to bringing something up. Or in our case, to raise a number to the next one.
#technology #software-engineering #math #javascript #web-development