JavaScript lesson 1 of 50 · Beginner · About 15 minutes
Send Pip’s first radio messages from Central Hub and watch each instruction run in order.

Get ready
Open Complete checkpoint below. Paste the JavaScript into a blank JavaScript editor and run it. Language to look for JavaScript, console, console.log(), strings, comments, statements. A program is a set of instructions. Start by copying the first two lines and running them. The line beginning In Add the second message below the first, then place this third message underneath it. JavaScript reads these instructions from top to bottom, so Pip speaks in the order you wrote. Each semicolon marks the end of a statement. Run the whole file and compare the three output lines with the three 
Understand the JavaScript in this lesson
1. Read the first instruction
// is a comment. It gives a human a clue about the code and JavaScript skips it. The second line is a statement, a single instruction to do something.// Sky Island Rescue: Pip checks in from Central Hub.
console.log("Pip is at Central Hub.");2. Send a message to the console
console.log(...), the dot means “use something from”. JavaScript finds the log tool on console. Parentheses call that tool and hold what you want it to show. Text between matching quotes is a string. The quote marks help JavaScript find the edges of the text. You see the words inside them in the console output.console.log("A cloud creature needs help.");3. Put Pip’s instructions in order
console.log() calls. Change one message and run again. This is how you check that an edit did the job you expected.console.log("Our first stop is the Workshop.");
The line starting with // makes no output.Why It is a comment, so JavaScript skips it.
Pip is at Central Hub.Why JavaScript passes the text in quotes to console.log().
A cloud creature needs help. Then the Workshop message appears.Why This program runs statements from top to bottom.
Predict before you run What changes if you swap the second and third calls?
Reveal the answer
The last two messages swap positions in the output. Their words stay the same.
Complete checkpoint
JavaScript · the instructions
// Sky Island Rescue: Pip checks in from Central Hub.
console.log("Pip is at Central Hub.");
console.log("A cloud creature needs help.");
console.log("Our first stop is the Workshop.");
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 2–6
-
Line 2
console.log("Pip is at Central Hub."); - Show a message or value in the output. Use it to watch the game work.
-
Line 4
console.log("A cloud creature needs help."); - Show a message or value in the output. Use it to watch the game work.
-
Line 6
console.log("Our first stop is the Workshop."); - Show a message or value in the output. Use it to watch the game work.
Mission challenge
Add a fourth call that tells Pip where the Beacon is. Run it and check that the new line appears last.
Change one piece at a time. Run the checkpoint again and compare what you expected with what actually happened.