Math.. our favorite! :D

Photo by Jeswin Thomas on Unsplash

When I first got into the computer science world, I was super nervous about all of the math that would be involved in coding. There can be tons of math involved, but luckily it’s usually pretty simple in my situation. JavaScript even has quite a few built in tools to help with any math! Let’s take a look at some of them.

That’s easy enough. On to the next!

Easy enough, we all know how to round.

Now we’re starting to get to things that I might not be able to do in my head!

^^ A very simple example, but very useful!

This returns the absolute value of the number you give it.

This will return the value of what it is given rounded up to the nearest integer.

This will return the value of what it is given rounded down to the nearest integer.

Very very helpful for when you just need some test info.. But what else could it be used for?

Helpful if you need to check multiple numbers and just pick out the single highest or lowest.

There are also some built in constants that are available for use off the bat.

I don’t believe I’ve ever actually used any of these.. But in the situation that I do need them, I know for a fact that I will be extremely grateful for them.

Most of these seem pretty simple in their explanation, but when you think about the uses of them, and how you can incorporate them into logic, the options are endless!

I hope that you find these useful, and will try and find some fun ways to incorporate them into your projects. Happy coding!