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

Conteúdo do Curso

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

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

bookNumber 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

+ 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
Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 12
toggle bottom row

bookNumber 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

+ 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
Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 12
toggle bottom row

bookNumber 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

+ 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
Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

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

+ 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
Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 12
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt