javascript · level 1 · unit 1 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
shows a message on the screen.
console.log writes a message in the console, the area where your program's messages appear. Log means write down, like a captain's logbook. There is a dot in the middle and no spaces.
Whatever is inside the brackets is what appears. Words go inside quote marks, like "Hello, world!". A piece of text in quotes is called a . Picture the letters threaded on a string, like beads.
The quotes tell JavaScript where your text starts and stops, and they are not shown. The ; at the end finishes the instruction, like a full stop finishes a sentence.
console.log("Hello, world!"); Use the same quote mark at both ends of your string.
guess first
What will appear on the screen?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
console.log("My hamster is called Nibbles");
your turn
Your turn. Tell the computer your favourite film.
Type the best film you have ever seen in place of the blank, keeping it inside the quotes. Then press run.
fix it
This line will not run. Can you fix it?
- Compare this line with the example above. Look closely at the first two words.
consoleandlogmust be joined by a dot, with no space between them.- Change the space between console and log into a dot, so it reads console.log, then press run.
nailed it
you made the computer talk. :D
console.logshows whatever is inside its brackets.- Text inside quote marks is called a string.
- A semicolon ends each instruction, like a full stop.
new words in your collection
- console
- string
- semicolon
This lesson isn’t saved. A free account remembers every lesson you finish.