GCGrowCarrer

Variables and Primitive Types

Available

Lesson 1 of 25 · Syntax · Easy

Mastery0% of 85%
1

The big idea

A variable is a named spot where JavaScript remembers a value for you. In JavaScript, write let (or const if the value will not change), then the name, an equals sign =, and the value: JavaScript detects whether a value is a number, text, or true/false automatically.

Think of it like this: Think of a variable like a labeled jar on a shelf: `let x = 5;` puts a label called `x` on the jar and drops `5` inside.
Key words (tap to learn):
2

Read the lesson

A variable is a named spot where JavaScript remembers a value for you.

In JavaScript, write let (or const if the value will not change), then the name, an equals sign =, and the value:

let age = 20;        // a number
const price = 9.99;  // a decimal number
let name = "Maya";   // text (a string)
let isReady = true;  // true or false (a boolean)

JavaScript detects whether a value is a number, text, or true/false automatically. You do not need to write a type name.

3

Quick check

Which keyword creates a variable in modern JavaScript?

4

Your challenge

2 sample tests, 1 hidden

Create a variable named x and set it to 5 (type let x = 5;).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to python.variables-types (85% overlap). Variables & primitive types: compare let/const (JS), auto/int (C++), := (Go), let mut (Rust), and column types (SQL).

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Variables and Primitive Types.

Mastery0%

Learn this first

Nothing needed - you can start here.