JavaScript lesson 2 of 50 · Beginner · About 20 minutes
Use names for Pip’s tools and keep track of a location that can change.

Get ready
Open Complete checkpoint below. Paste the JavaScript into a blank JavaScript editor and run it. Language to look for const, let, variable names, assignment, reassignment, comma. Rather than writing Pip’s name in every message, store the string once under Put the printing instructions below the declarations. In the first call, The program first gives 
Understand the JavaScript in this lesson
1. Name the details that stay fixed
rover. The keyword const declares a name that cannot be reassigned to a different value. The = sign gives the name its value. Pick clear names so you can later read a sentence like “show the rover”. Variable names are case-sensitive, so rover and Rover refer to different names.const rover = "Pip";
const task = "Restore the wind beacon";
let location = "Central Hub";2. Read the value using its name
"Rover:" is a fixed string. After the comma, rover is a name without quotes. JavaScript looks up its current value and gives both pieces to console.log(). Writing "rover" there would show the word rover instead of looking up Pip’s name.console.log("Rover:", rover);
console.log("Task:", task);
console.log("Starting location:", location);3. Update the detail that changes
location the value "Central Hub" with let because Pip can move. Add the Workshop lines last. The new assignment uses the same name without writing let again. JavaScript now uses the new location whenever a later instruction reads it. Move the last print statement before the assignment and check which value appears.location = "Workshop";
console.log("Current location:", location);
rover is Pip, task is the rescue goal, and location is Central Hub.Why The assignment on each line connects a name to a value.
Starting location: Central HubWhy Pip has not moved yet.
Current location: WorkshopWhy Later uses of a let name see its most recent assigned value.
Predict before you run What happens if you change let location to const location at the top?
Reveal the answer
The first three messages still work. The attempt to assign Workshop raises an error, so JavaScript does not reach the last print.
Complete checkpoint
JavaScript · the instructions
const rover = "Pip";
const task = "Restore the wind beacon";
let location = "Central Hub";
console.log("Rover:", rover);
console.log("Task:", task);
console.log("Starting location:", location);
location = "Workshop";
console.log("Current location:", location);
Read the JavaScript line by line
Open a small group of lines while you read the complete checkpoint. Blank lines separate ideas. Closing braces mark the end of a block. An ellipsis here means you can read the rest in the full program.
Lines 1–10
-
Line 1
const rover = "Pip"; - Set up rover. Keep this name attached to the same value.
-
Line 2
const task = "Restore the wind beacon"; - Set up task. Keep this name attached to the same value.
-
Line 3
let location = "Central Hub"; - Set up location. Give this name a starting value that later code can change.
-
Line 5
console.log("Rover:", rover); - Show a message or value in the output. Use it to watch the game work.
-
Line 6
console.log("Task:", task); - Show a message or value in the output. Use it to watch the game work.
-
Line 7
console.log("Starting location:", location); - Show a message or value in the output. Use it to watch the game work.
-
Line 9
location = "Workshop"; - Store the result in the name or property to the left.
-
Line 10
console.log("Current location:", location); - Show a message or value in the output. Use it to watch the game work.
Mission challenge
After the Workshop report, set location to Garden and print it again. Keep rover and task fixed.
Change one piece at a time. Run the checkpoint again and compare what you expected with what actually happened.