JavaScript
Lesson 1: What you will learn
You will learn how to ask JavaScript to display a message, and where to read that message after selecting Run code. No coding experience is needed. First, picture a noticeboard; then use a detective story to write your own update.
Help Maya find the missing bag
Let’s learn through a story. Detective Maya is looking for a missing bag. She spots a clue near the doorway and pins a note on her investigation board: ‘Clue found near the door.’ In our program, we will display the same update using console.log().
Definition in English: console.log() is a method that writes values or messages to the console. In this workspace, those messages appear in Output.
Understand the code
// Record Maya’s clue
console.log("Clue found near the door.");// Record Maya’s clue- Two slashes start a note for people. JavaScript ignores that line. Put the instruction on the next line.
console- Think of Maya’s noticeboard. The console is the place where your program records messages; here, you read them in Output.
.log- Log means “record information.” .log tells the console to record the message you give it.
(...)- Put the message inside these round brackets. They tell log what to record.
"Clue found near the door."- Quotes tell JavaScript these words are text. Output shows the words, without the quotes.
;- A semicolon marks the end of this instruction. JavaScript can often work without it, but we include it in our examples.
Your turn: write it and run it
Maya has now found the missing bag. It is your turn to write her new message using console.log(). In the code editor, write a message that says "The missing bag has been found." Put the message inside quotes. Select Run code and see what appears in Output. Does it match the message below?
Expected output, one value per line:The missing bag has been found.
Need help with your own program?
Use console.log("your message");. Replace only the message with Maya’s new update. Keep the quotation marks and parentheses.
Maya finds a clue. How can her program show it?
Imagine Maya is a detective looking for a missing bag. She finds a clue near the door. She wants her computer to show the message ‘Clue found near the door’, so she types the line below using console.log(). When she selects Run code, the message appears in Output, like a note on her investigation board.
console — the noticeboard: where you read the message.
.log() — place a note: record the message. In everyday English, log means record information.
1. If Maya writes this line
console.log("Clue found near the door");The words inside quotes are your message.
↓ Select Run code
2. Output shows your message
Think of Output as a noticeboard. Only the message appears—not console.log, the quotes or the brackets. This is an illustration; run your own code in the editor to see its actual Output.
Check your understanding
You can revisit the story and retry. A run alone does not complete the lesson.
Explain it in your own words (optional reflection)
Saved for your review. Written explanations and spelling are not automatically graded. Ask a trainer for feedback.Write your code, then select Run.
Unlock the next lesson
- ○ Coding task
- ○ Concept and prediction checks
Complete the task and both understanding checks to continue.
Let’s follow the story and see this idea in action. Select Continue to begin.
Maya has now found the missing bag. It is your turn to write her new message using console.log(). In the code editor, write a message that says "The missing bag has been found." Put the message inside quotes. Select Run code and see what appears in Output. Does it match the message below?
// Record Maya’s clue
console.log("Clue found near the door.");First follow the story. Your own code is kept when you revisit these steps.
Output
Your output will appear here.
Write your code, then select Run.
Console-only practice. No network, DOM or package imports. Each run has a two-second limit. Use fictional data.