OK, Most of these require “Math” in front of them, so if you don't see them There just assume Math comes before it. Here we go!
.random(): Here we are using the Math method followed by .random(). All this does is generates a random number. To be even more specific, it will generate numbers more than 0 but less than 1.
.floor() : this will always round a decimal down (hint, the floor =’s down).
Say you wanted a random number between 0–19 you would multiply it by twenty and then run, Math.floor() which then rounds it down. (It won't land on 20 because it always rounds down.)
I've also done a range between 0–99 just so you know that, whatever you multiply it by, you get all the numbers right below the number you put, and 0. (it will never land on the “100"! because it always rounds down, thus never landing on 100.)
.round() : this will return a value rounded to its nearest integer. I put a decimal at 3.6 and 3.4 to show you that it will round up or down to the nearest whole number in either direction.
.pow() : this takes in two arguments one being the number to multiply with and the second is how many times to multiply itself by.
Here we see that the first argument in “.pow” is the main number, then the second number is how many times we are going to multiple that first number by. (so Math.pow(2,6) its the same as saying this: 2*2*2*2*2*2 = 64)
.abs() : this will give you the absolute value of a number (Basically just give you a whole number if it's negative.) if you see below, it changes all negative inputs into positives.
.ceil() : this will round up to the the nearest whole number(aka: ceiling = up). see no matter what, it will always round up from any range to the nearest number.
.min() : this will look through an array of numbers and return the LOWEST number. (It looks through the numbers and finds the minimum) Plain and simple!
.max() : this will look through an array of numbers and return the HIGHEST number. (It looks through the numbers and finds the maximum.)
.parseInt() : this will take any string and convert it to a number. here we use it on “007” and it made it a solid 7 number. If you were to use this on a word it would give you. “NaN” is not a number, And the last part is a simple number in a form of a string and turned into a “real number”.
well, that's enough math for one day!
See you all next time
The Social Media…