Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Number 3/3 | Data Types and Variables
Introduction to JavaScript (staging)
course content

Зміст курсу

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

bookNumber 3/3

Other Math Functions

JavaScript has a library by the name of Math that has many built-in mathematics functions and methods. Let’s look at a few of them.

  • Math.random():
    The Math.random() is a function in JavaScript, that gives random numbers between 0 and 1 but not including 1, for example.
123
console.log(Math.random()); console.log(Math.random()); console.log(Math.random());
copy

As you can see we get three different numbers between 0 and 1.

Note:
You may get different output as Math.random() gives random numbers.

  • Math.max() and Math.min():
    The Math.max() returns the greatest number of all the numbers passed in as an argument while Math.min() returns the smallest one.
12
console.log(Math.max(3, 5, -10, 100, 1)); console.log(Math.min(1, 2, 6, 0, -15));
copy
  • Math.pow(base, power):
    The Math.pow(base, power) returns base raised to the given power, for example.
1
console.log(Math.pow(2, 10));
copy

Завдання

The task is to find the volume of a cylinder. The radius and height variables are given to storing the radius and the height of the cylinder. The formula for the volume of the cylinder is:
V = πhr²
where π is the Math PI having the value of 3.1415, r is the radius, and h is the height. Your task is to create a new const variable named PI and store 3.1415 in it and implement this formula storing the result in a variable named volume.

Summary

  • JavaScript provides the facility of rounding numbers.
  • We can check whether a variable is finite or infinite through the isFinite() function.
  • We can check whether a variable is a number or not through the isNaN() function.
  • The Math.random() function is used to get a random numeric value from 0 to 1(excluding 1).

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 14
toggle bottom row

bookNumber 3/3

Other Math Functions

JavaScript has a library by the name of Math that has many built-in mathematics functions and methods. Let’s look at a few of them.

  • Math.random():
    The Math.random() is a function in JavaScript, that gives random numbers between 0 and 1 but not including 1, for example.
123
console.log(Math.random()); console.log(Math.random()); console.log(Math.random());
copy

As you can see we get three different numbers between 0 and 1.

Note:
You may get different output as Math.random() gives random numbers.

  • Math.max() and Math.min():
    The Math.max() returns the greatest number of all the numbers passed in as an argument while Math.min() returns the smallest one.
12
console.log(Math.max(3, 5, -10, 100, 1)); console.log(Math.min(1, 2, 6, 0, -15));
copy
  • Math.pow(base, power):
    The Math.pow(base, power) returns base raised to the given power, for example.
1
console.log(Math.pow(2, 10));
copy

Завдання

The task is to find the volume of a cylinder. The radius and height variables are given to storing the radius and the height of the cylinder. The formula for the volume of the cylinder is:
V = πhr²
where π is the Math PI having the value of 3.1415, r is the radius, and h is the height. Your task is to create a new const variable named PI and store 3.1415 in it and implement this formula storing the result in a variable named volume.

Summary

  • JavaScript provides the facility of rounding numbers.
  • We can check whether a variable is finite or infinite through the isFinite() function.
  • We can check whether a variable is a number or not through the isNaN() function.
  • The Math.random() function is used to get a random numeric value from 0 to 1(excluding 1).

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 14
toggle bottom row

bookNumber 3/3

Other Math Functions

JavaScript has a library by the name of Math that has many built-in mathematics functions and methods. Let’s look at a few of them.

  • Math.random():
    The Math.random() is a function in JavaScript, that gives random numbers between 0 and 1 but not including 1, for example.
123
console.log(Math.random()); console.log(Math.random()); console.log(Math.random());
copy

As you can see we get three different numbers between 0 and 1.

Note:
You may get different output as Math.random() gives random numbers.

  • Math.max() and Math.min():
    The Math.max() returns the greatest number of all the numbers passed in as an argument while Math.min() returns the smallest one.
12
console.log(Math.max(3, 5, -10, 100, 1)); console.log(Math.min(1, 2, 6, 0, -15));
copy
  • Math.pow(base, power):
    The Math.pow(base, power) returns base raised to the given power, for example.
1
console.log(Math.pow(2, 10));
copy

Завдання

The task is to find the volume of a cylinder. The radius and height variables are given to storing the radius and the height of the cylinder. The formula for the volume of the cylinder is:
V = πhr²
where π is the Math PI having the value of 3.1415, r is the radius, and h is the height. Your task is to create a new const variable named PI and store 3.1415 in it and implement this formula storing the result in a variable named volume.

Summary

  • JavaScript provides the facility of rounding numbers.
  • We can check whether a variable is finite or infinite through the isFinite() function.
  • We can check whether a variable is a number or not through the isNaN() function.
  • The Math.random() function is used to get a random numeric value from 0 to 1(excluding 1).

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Other Math Functions

JavaScript has a library by the name of Math that has many built-in mathematics functions and methods. Let’s look at a few of them.

  • Math.random():
    The Math.random() is a function in JavaScript, that gives random numbers between 0 and 1 but not including 1, for example.
123
console.log(Math.random()); console.log(Math.random()); console.log(Math.random());
copy

As you can see we get three different numbers between 0 and 1.

Note:
You may get different output as Math.random() gives random numbers.

  • Math.max() and Math.min():
    The Math.max() returns the greatest number of all the numbers passed in as an argument while Math.min() returns the smallest one.
12
console.log(Math.max(3, 5, -10, 100, 1)); console.log(Math.min(1, 2, 6, 0, -15));
copy
  • Math.pow(base, power):
    The Math.pow(base, power) returns base raised to the given power, for example.
1
console.log(Math.pow(2, 10));
copy

Завдання

The task is to find the volume of a cylinder. The radius and height variables are given to storing the radius and the height of the cylinder. The formula for the volume of the cylinder is:
V = πhr²
where π is the Math PI having the value of 3.1415, r is the radius, and h is the height. Your task is to create a new const variable named PI and store 3.1415 in it and implement this formula storing the result in a variable named volume.

Summary

  • JavaScript provides the facility of rounding numbers.
  • We can check whether a variable is finite or infinite through the isFinite() function.
  • We can check whether a variable is a number or not through the isNaN() function.
  • The Math.random() function is used to get a random numeric value from 0 to 1(excluding 1).

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 14
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt