JavaScript Curriculum
Name It, Store It
easyYour tech lead drops a task in Slack: 'The word \"Nexus\" appears 47 times in the codebase. Hardcoded everywhere. If we ever rebrand, we're dead. Store it in a variable.' You stare at the editor. You've seen `const` and `let` before but never really understood what they do. Time to find out.
The tech lead's Slack message
"We have 'Nexus' hardcoded in 47 places. If we rebrand tomorrow, someone has to find and change all 47. Store it in a variable. That's what variables are for."
This is the actual reason variables exist. Not because programming textbooks say so. Because repeating the same value everywhere is a maintenance nightmare.
What is a variable?
A variable is a named container that holds a value.
Think of it like a labeled box. You write a name on the outside, put a value inside, and then use the name whenever you need the value.
Watch this:
Now instead of typing "Nexus" 47 times, you type companyName 47 times. And when the company rebrands to "Apex", you change one line.
const — your default choice
const creates a variable that cannot be reassigned after you give it a value.
Use const for anything that shouldn't change: company names, user IDs, configuration values, API endpoints. This is your default. Reach for const first, every time.
let — when the value needs to change
let creates a variable that can be reassigned. Use it when the value will be updated — a score that goes up, a counter that increments, a status that flips.
See the difference in action — click "next" to step through:
var — the old way. Don't use it.
var is how JavaScript worked before 2015. It has weird scoping rules that cause subtle bugs. You'll see it in old code and tutorials, but never write it yourself.
| keyword | reassign? | redeclare? | scope | use when |
|---|---|---|---|---|
| const | ✗ No | ✗ No | Block | Default choice |
| let | ✓ Yes | ✗ No | Block | When value changes |
| var | ✓ Yes | ✓ Yes | Function | ⚠️ Avoid — legacy |
Naming your variables
The name you give a variable matters. A lot. Bad names make code unreadable. Good names make code self-documenting.
The rules JavaScript enforces:
- Must start with a letter,
_, or$(not a number) - No spaces
- No reserved keywords (
const,let,if, etc.)
The convention JavaScript developers follow:
camelCasefor everything — first word lowercase, each subsequent word capitalized- Names that describe what the value is, not how it's used
Click any name below to see why it's good, questionable, or broken:
camelCase — clear and readable
How JavaScript executes variable code
The three things you do with variables
Before the challenge
Your challenge uses three variables — one for each type of data the dashboard tracks. Before you write them, think:
- Should any of these change at runtime? (Probably not for this challenge — use
const) - What names make the code readable without comments?
Challenge
The Nexus dashboard needs three pieces of data: the company name (\"Nexus\"), the current user count (1042), and whether the system is online (true). Create three variables using const — companyName, userCount, and isOnline — then log all three with descriptive labels like: console.log(\"Company:\", companyName).
Name It, Store It
easyYour tech lead drops a task in Slack: 'The word \"Nexus\" appears 47 times in the codebase. Hardcoded everywhere. If we ever rebrand, we're dead. Store it in a variable.' You stare at the editor. You've seen `const` and `let` before but never really understood what they do. Time to find out.
The tech lead's Slack message
"We have 'Nexus' hardcoded in 47 places. If we rebrand tomorrow, someone has to find and change all 47. Store it in a variable. That's what variables are for."
This is the actual reason variables exist. Not because programming textbooks say so. Because repeating the same value everywhere is a maintenance nightmare.
What is a variable?
A variable is a named container that holds a value.
Think of it like a labeled box. You write a name on the outside, put a value inside, and then use the name whenever you need the value.
Watch this:
Now instead of typing "Nexus" 47 times, you type companyName 47 times. And when the company rebrands to "Apex", you change one line.
const — your default choice
const creates a variable that cannot be reassigned after you give it a value.
Use const for anything that shouldn't change: company names, user IDs, configuration values, API endpoints. This is your default. Reach for const first, every time.
let — when the value needs to change
let creates a variable that can be reassigned. Use it when the value will be updated — a score that goes up, a counter that increments, a status that flips.
See the difference in action — click "next" to step through:
var — the old way. Don't use it.
var is how JavaScript worked before 2015. It has weird scoping rules that cause subtle bugs. You'll see it in old code and tutorials, but never write it yourself.
| keyword | reassign? | redeclare? | scope | use when |
|---|---|---|---|---|
| const | ✗ No | ✗ No | Block | Default choice |
| let | ✓ Yes | ✗ No | Block | When value changes |
| var | ✓ Yes | ✓ Yes | Function | ⚠️ Avoid — legacy |
Naming your variables
The name you give a variable matters. A lot. Bad names make code unreadable. Good names make code self-documenting.
The rules JavaScript enforces:
- Must start with a letter,
_, or$(not a number) - No spaces
- No reserved keywords (
const,let,if, etc.)
The convention JavaScript developers follow:
camelCasefor everything — first word lowercase, each subsequent word capitalized- Names that describe what the value is, not how it's used
Click any name below to see why it's good, questionable, or broken:
camelCase — clear and readable
How JavaScript executes variable code
The three things you do with variables
Before the challenge
Your challenge uses three variables — one for each type of data the dashboard tracks. Before you write them, think:
- Should any of these change at runtime? (Probably not for this challenge — use
const) - What names make the code readable without comments?
Challenge
The Nexus dashboard needs three pieces of data: the company name (\"Nexus\"), the current user count (1042), and whether the system is online (true). Create three variables using const — companyName, userCount, and isOnline — then log all three with descriptive labels like: console.log(\"Company:\", companyName).