What you’ll learn
- What a variable is
- How to create variables with
let - Locking values with
const - Why we (mostly) avoid
var - The rules for naming variables
- What
undefinedmeans - How to update variables using their old value
- Your first mini project: a receipt
The pages
Nine pages, about 14 minutes.
- What Is a Variable? Imagine you're moving to a new house. You've got a whole pile of stuff to pack, so you grab some cardboard boxes. You…
- Creating Variables with let Here's how you create a variable in JavaScript. Let's take this apart, piece by piece. So let age = 25; reads like…
- const: Boxes With Locks Sometimes you have a value that should never change. The number of days in a week. The value of pi. Your birthday. For…
- var: Grandpa's Old Box If you look at older JavaScript code online (anything written before about 2015), you'll see variables created with a…
- Naming Your Variables Naming things is one of the trickiest parts of programming. There's an old programmer joke. "There are only two hard…
- Declaring, Assigning, and undefined Here's something interesting. You don't have to put a value into a let box right away. You can create an empty box now…
- Variables Working Together Variables become really useful when you start combining them. JavaScript looks inside the boxes, finds 45 and 3…
- Mini Project: The Café Receipt Time to put it all together! Let's write a program that prints a receipt for a meal at a café. Look at that! A real…
- Recap The key ideas of Grade 1, JavaScript variables, on one page. A variable is a named box that holds a value. Create…
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.