JavaScript Math

Common Math Methods

  1. Math.abs():

Explanation of Code:

Returns the absolute value of a number.

JavaScript
  1. Math.ceil():

Explanation of Code:

Tutorials dojo strip

Rounds a number up to the nearest integer.

JavaScript
  1. Math.floor():

Explanation of Code:

Rounds a number down to the nearest integer.

JavaScript
  1. Math.round():

Explanation: of Code:

Rounds a number to the nearest integer.

JavaScript
  1. Math.max():

Explanation of Code:

Returns the largest of the given numbers.

JavaScript
  1. Math.min():

Explanation of Code:

Returns the smallest of the given numbers.

JavaScript
  1. Math.random():

Explanation of Code:

Returns a random number between 0 (inclusive) and 1 (exclusive).

JavaScript
  1. Math.sqrt():

Explanation of Code:

Returns the square root of a number.

JavaScript

JavaScript Math Example Code

Explanation of Code:

This HTML file sets up a random integer generator that displays a random integer between 1 and 100.

HTML

JavaScript Labs

Tutorials dojo strip