Learn
Getting Started with JavaScript
Built-in Objects
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:
Math Object
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:
Instructions
1.
Print the value of Math.PI to the console.
2.
Print the result of the square root of 16 using the Math.sqrt() method.
Stuck? Get a hint
Square root of 9 is used like:
Math.sqrt(9)Sign up to start coding
Already have an account?
Sign In
Course content
