DEV Community

Javascript Arithmetic Cheat Sheet

Kelvin Wangonya on March 05, 2019

Given that one of the main reason computers were invented was to solve mathematical problems quickly, it is no wonder that all the modern programmi...
Collapse
 
oscherler profile image
Olivier “Ölbaum” Scherler

Nice write up. You could add an example with a negative number for Math.round().

About the use of Infinity, I think it’s useful when you are comparing results. If you do something like if(1/x > 1/y) and one of x or y turns out to be 0, then the comparison still works.

Collapse
 
wangonya profile image
Kelvin Wangonya

Thanks! I've added the example and your note on the use of infinity.

Collapse
 
modjular profile image
Tony Reksoatmodjo

On your second decrementing example, did you mean to have only one - sign?

Collapse
 
wangonya profile image
Kelvin Wangonya

Oops. My mistake. Fixed. Thanks!

Collapse
 
madhavgupta profile image
Madhav Gupta

Nice post,how do you add the black background with your coding examples?

Collapse
 
wangonya profile image
Kelvin Wangonya

Hi! I just set what I want to appear as code in a "code block" by surrounding it with three backticks "`" at the start and at the end. Check this out for examples.