Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Introduction to Numbers | Numbers Booleans and Core Primitives
Quizzes & Challenges
Quizzes
Challenges
/
JavaScript Data Types Foundations

bookIntroduction to Numbers

Numbers are one of the most fundamental data types in JavaScript, representing numeric values that you use for a wide variety of everyday tasks. Whenever you need to store or process prices, scores, measurements, or any other kind of numeric information, you will use the number type. Whether you are calculating a total price in a shopping cart, tracking a player's score in a game, or measuring the distance traveled, numbers are essential.

12345678910111213
// Declaring number variables let price = 19.99; let score = 42; let distance = 3.5; // Performing simple arithmetic let totalCost = price * 3; // Multiplying price by quantity let newScore = score + 10; // Adding points to score let halfDistance = distance / 2; // Dividing distance by 2 console.log(totalCost); // 59.97 console.log(newScore); // 52 console.log(halfDistance); // 1.75
copy

In JavaScript, numbers can be either integers (whole numbers like 10, -3, or 0) or floating-point numbers (numbers with a decimal point like 3.14, -0.5, or 100.0). Both types are treated as the same number type in JavaScript, so you do not need to declare them differently. This makes working with numbers flexible, but it is important to be aware that floating-point numbers can sometimes behave unexpectedly in calculations due to how computers represent decimal values.

question mark

Which of the following is true about numbers in JavaScript?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 1

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Awesome!

Completion rate improved to 6.25

bookIntroduction to Numbers

Veeg om het menu te tonen

Numbers are one of the most fundamental data types in JavaScript, representing numeric values that you use for a wide variety of everyday tasks. Whenever you need to store or process prices, scores, measurements, or any other kind of numeric information, you will use the number type. Whether you are calculating a total price in a shopping cart, tracking a player's score in a game, or measuring the distance traveled, numbers are essential.

12345678910111213
// Declaring number variables let price = 19.99; let score = 42; let distance = 3.5; // Performing simple arithmetic let totalCost = price * 3; // Multiplying price by quantity let newScore = score + 10; // Adding points to score let halfDistance = distance / 2; // Dividing distance by 2 console.log(totalCost); // 59.97 console.log(newScore); // 52 console.log(halfDistance); // 1.75
copy

In JavaScript, numbers can be either integers (whole numbers like 10, -3, or 0) or floating-point numbers (numbers with a decimal point like 3.14, -0.5, or 100.0). Both types are treated as the same number type in JavaScript, so you do not need to declare them differently. This makes working with numbers flexible, but it is important to be aware that floating-point numbers can sometimes behave unexpectedly in calculations due to how computers represent decimal values.

question mark

Which of the following is true about numbers in JavaScript?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 1
some-alt