There are several built-in objects that provide a wide range of functionality. We already used the
console object a lot.
Let's take a look at the
Math object provides mathematical operations and constants. It has properties and methods for performing various calculations. The most common
Math object methotds are:
Math.random() - This method returns a random number between 0 (inclusive) and 1 (exclusive)
Math.floor() - Rounds the number down to the nearest whole number.
You can also combine multiple object methodes like so:
Print the value of
Math.PI to the console.
Print the result of the square root of 16 using the
Square root of 9 is used like:
Sign up to start coding
Already have an account?