Minds
It is Recommended to practice while you learn

Math Functions

TThe JavaScript Math object allows you to perform mathematical tasks on numbers.




syntax :

Math.PI // returns PI
Math.E // returns Euler's number
Math.SQRT2 // returns the square root of 2
Math.SQRT1_2 // returns the square root of 1/2
Math.LN2 // returns the natural logarithm of 2
Math.LN10 // returns the natural logarithm of 10
Math.LOG2E // returns base 2 logarithm of E
Math.LOG10E // returns base 10 logarithm of E



syntax :

Math.round(x) // Returns x rounded to its nearest integer
Math.ceil(x) //Returns x rounded up to its nearest integer
Math.floor(x) // Returns x rounded down to its nearest integer
Math.trunc(x) // Returns the integer part of x (new in ES6)
Math.Min(x,y,z) // returns the min value from given values
Math.Max(x,y,z) // returns the max value from given values
Math.abs(x) // returns possitive value of x
Math.sqrt(x) // returns square root of x
Math.pow(x,y) // returns x to power y
Math.random(); // returns a random number between 0 (inclusive), and 1 (exclusive)