Math Obj properties and methods Flashcards
What properties does the math object have?
Math.PI() returns Ratio of the circumference of a circle to its diameter, approximately 3.14159.
What method returns the absolute value of a number?
Math.abs(n)
What method returns the cube root of a number?
Math.cbrt(n)
What method rounds numbers down to the nearest integer? or what about up to the nearest?
Math.floor(n) Math.ceil(n)
What method returns the max number out of a group? syntax?
Math.max() will take numbers separated by commas or an array passed as a variable with spread operator
What method returns the min number out of a group? syntax?
Math.max() will take numbers separated by commas or an array passed as a variable with spread operator
What method returns a number to the n root? how does this differ from the other root function?
Math.sqrt(x) Returns the positive square root of a number.
Returns the integer part of the number x, removing any fractional digits.
Math.trunc(x)
Method Returns a pseudo-random number between 0 and 1. How do we get it to a certain number range?
Math.random()
function getRandomArbitrary(min, max) { return Math.random() * (max - min) + min; }