Code highlights logo


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:

1console.log(Math.floor(Math.random() * 50)); // Prints a random whole number between 0 and 50



Print the value of Math.PI to the console.


Print the result of the square root of 16 using the Math.sqrt() method.

Sign up to start coding

Already have an account?

Sign In

Course content