Menu
Coddy logo textTech

Numbers

Part of the Fundamentals section of Coddy's JavaScript journey — lesson 5 of 77.

Variables are containers that hold data values. They are used to store, manipulate, and display information within a program.

In short, a variable is like a memory unit that we can access by typing the name of the variable. 

Each variable has a unique name and a value that can be of different types. JavaScript is capable of automatically detecting the variable type, which makes coding more efficient.

To initialize a variable, we use the following format:

let variable_name = value

Let's take a look at the different types of numbers:

JavaScript has a number type that can represent both integers and floating-point numbers.

number - can be a whole number, such as 1 or -2, or a real number, such as 1.32 or 0.98.

For example:

To initialize a variable of type number with the name a and the value 3:

let a = 3

To initialize a variable of type number with the name b and the value 13.2:

let b = 13.2
challenge icon

Challenge

Beginner

Write code that initializes a variable named c with the value 5.

Cheat sheet

Variables are containers that hold data values. To initialize a variable, use the let keyword:

let variable_name = value

JavaScript has a number type that can represent both integers and floating-point numbers:

let a = 3      // integer
let b = 13.2   // floating-point

Try it yourself

// Type your code below
let c = ?

// Don't change the line below
console.log(`c = ${c}`)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals