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

Course Content

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

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

Number 1/3

Numbers in JavaScript

JavaScript provides us with double-precision floating-point number to deal with the numbers in the code. You don’t need to specifically write int or float for declaring integer or floating values, unlike other programming languages.

12
let totalPlayer=10; console.log(totalPlayer);
copy

<code class="go3679463865">+</code> Operator with Numbers:

+ operator is used in two ways with the number data type.

  • Addition: + is used for addition when both the operands are numbers, for example.
1234
let firstNumber = 10; let secondNumber = 20; let total = firstNumber + secondNumber; console.log(total);
copy
  • Concatenation:
    When one operand is a number while the other is a string, the + operator concatenate them together, for example.
1234
let company = 'Robotech '; let version = 10; let newLaunch = company + version; console.log(newLaunch);
copy

JavaScript NaN and Infinity:

In JavaScript, the number datatype has some exceptions which are called “Special Numeric Values”. The exceptions are:

  • NaN:
    NaN stands for Not a Number. NaN, in JavaScript, is a keyword that is used to check whether the value or variable is not a number.
    We get NaN as a result when we perform arithmetic operations other than + between a numeric value and a string value, for example.
1234
let numberOfStudent = 20; let greeting = 'Hello'; let total = numberOfStudent - greeting; console.log(total);
copy
  • Infinity:
    We get Infinity or -Infinity, in JavaScript, if the result of a calculation exceeds the largest possible number or the smallest possible number respectively, for example.
12
console.log("2 / 0 :", 2 / 0) console.log("-2 / 0 :", -2 / 0)
copy

In JavaScript, you can use the isFinite() function to check whether a value or variable is Finite or not, for example.

1234
let score = 123; let status = 'Test'; console.log(isFinite(score)); console.log(isFinite(status));
copy

Note:
If isNaN() returns true, it means that the data type is not a number.

12
let name = 'Bob'; console.log(isNaN(name));
copy

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 12
toggle bottom row

Number 1/3

Numbers in JavaScript

JavaScript provides us with double-precision floating-point number to deal with the numbers in the code. You don’t need to specifically write int or float for declaring integer or floating values, unlike other programming languages.

12
let totalPlayer=10; console.log(totalPlayer);
copy

<code class="go3679463865">+</code> Operator with Numbers:

+ operator is used in two ways with the number data type.

  • Addition: + is used for addition when both the operands are numbers, for example.
1234
let firstNumber = 10; let secondNumber = 20; let total = firstNumber + secondNumber; console.log(total);
copy
  • Concatenation:
    When one operand is a number while the other is a string, the + operator concatenate them together, for example.
1234
let company = 'Robotech '; let version = 10; let newLaunch = company + version; console.log(newLaunch);
copy

JavaScript NaN and Infinity:

In JavaScript, the number datatype has some exceptions which are called “Special Numeric Values”. The exceptions are:

  • NaN:
    NaN stands for Not a Number. NaN, in JavaScript, is a keyword that is used to check whether the value or variable is not a number.
    We get NaN as a result when we perform arithmetic operations other than + between a numeric value and a string value, for example.
1234
let numberOfStudent = 20; let greeting = 'Hello'; let total = numberOfStudent - greeting; console.log(total);
copy
  • Infinity:
    We get Infinity or -Infinity, in JavaScript, if the result of a calculation exceeds the largest possible number or the smallest possible number respectively, for example.
12
console.log("2 / 0 :", 2 / 0) console.log("-2 / 0 :", -2 / 0)
copy

In JavaScript, you can use the isFinite() function to check whether a value or variable is Finite or not, for example.

1234
let score = 123; let status = 'Test'; console.log(isFinite(score)); console.log(isFinite(status));
copy

Note:
If isNaN() returns true, it means that the data type is not a number.

12
let name = 'Bob'; console.log(isNaN(name));
copy

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 12
toggle bottom row

Number 1/3

Numbers in JavaScript

JavaScript provides us with double-precision floating-point number to deal with the numbers in the code. You don’t need to specifically write int or float for declaring integer or floating values, unlike other programming languages.

12
let totalPlayer=10; console.log(totalPlayer);
copy

<code class="go3679463865">+</code> Operator with Numbers:

+ operator is used in two ways with the number data type.

  • Addition: + is used for addition when both the operands are numbers, for example.
1234
let firstNumber = 10; let secondNumber = 20; let total = firstNumber + secondNumber; console.log(total);
copy
  • Concatenation:
    When one operand is a number while the other is a string, the + operator concatenate them together, for example.
1234
let company = 'Robotech '; let version = 10; let newLaunch = company + version; console.log(newLaunch);
copy

JavaScript NaN and Infinity:

In JavaScript, the number datatype has some exceptions which are called “Special Numeric Values”. The exceptions are:

  • NaN:
    NaN stands for Not a Number. NaN, in JavaScript, is a keyword that is used to check whether the value or variable is not a number.
    We get NaN as a result when we perform arithmetic operations other than + between a numeric value and a string value, for example.
1234
let numberOfStudent = 20; let greeting = 'Hello'; let total = numberOfStudent - greeting; console.log(total);
copy
  • Infinity:
    We get Infinity or -Infinity, in JavaScript, if the result of a calculation exceeds the largest possible number or the smallest possible number respectively, for example.
12
console.log("2 / 0 :", 2 / 0) console.log("-2 / 0 :", -2 / 0)
copy

In JavaScript, you can use the isFinite() function to check whether a value or variable is Finite or not, for example.

1234
let score = 123; let status = 'Test'; console.log(isFinite(score)); console.log(isFinite(status));
copy

Note:
If isNaN() returns true, it means that the data type is not a number.

12
let name = 'Bob'; console.log(isNaN(name));
copy

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Numbers in JavaScript

JavaScript provides us with double-precision floating-point number to deal with the numbers in the code. You don’t need to specifically write int or float for declaring integer or floating values, unlike other programming languages.

12
let totalPlayer=10; console.log(totalPlayer);
copy

<code class="go3679463865">+</code> Operator with Numbers:

+ operator is used in two ways with the number data type.

  • Addition: + is used for addition when both the operands are numbers, for example.
1234
let firstNumber = 10; let secondNumber = 20; let total = firstNumber + secondNumber; console.log(total);
copy
  • Concatenation:
    When one operand is a number while the other is a string, the + operator concatenate them together, for example.
1234
let company = 'Robotech '; let version = 10; let newLaunch = company + version; console.log(newLaunch);
copy

JavaScript NaN and Infinity:

In JavaScript, the number datatype has some exceptions which are called “Special Numeric Values”. The exceptions are:

  • NaN:
    NaN stands for Not a Number. NaN, in JavaScript, is a keyword that is used to check whether the value or variable is not a number.
    We get NaN as a result when we perform arithmetic operations other than + between a numeric value and a string value, for example.
1234
let numberOfStudent = 20; let greeting = 'Hello'; let total = numberOfStudent - greeting; console.log(total);
copy
  • Infinity:
    We get Infinity or -Infinity, in JavaScript, if the result of a calculation exceeds the largest possible number or the smallest possible number respectively, for example.
12
console.log("2 / 0 :", 2 / 0) console.log("-2 / 0 :", -2 / 0)
copy

In JavaScript, you can use the isFinite() function to check whether a value or variable is Finite or not, for example.

1234
let score = 123; let status = 'Test'; console.log(isFinite(score)); console.log(isFinite(status));
copy

Note:
If isNaN() returns true, it means that the data type is not a number.

12
let name = 'Bob'; console.log(isNaN(name));
copy

Task

A variable named comment with the assigned value of "hello123" has been given to you. Your task is to check and print whether the comment variable is a number or not as well as whether it is Finite or not.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 12
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt