Chapter 1 · Lesson 1 of 5
01. Your first JavaScript program
What JavaScript is and where it runs, and console.log to show words in the console.
JavaScript is the language of the web. Every website you use, from YouTube to your school's portal, runs JavaScript in your browser to make buttons work, show new messages and play games. It's the only language every browser understands.
Here's a whole JavaScript program. It shows one line in the console, the place programs write their messages.
console.log("Hello, World!");It shows
Hello, World!
console.log(…) shows what's in the brackets, then starts a new line. Words go in quotes: double "…" or single '…', both work. The semicolon ; ends the instruction.
A program runs from top to bottom, one line after another.
console.log("Good morning!");console.log("Ready to code?");console.log('Let\'s go!');It shows
Good morning! Ready to code? Let's go!
Your turn
1Steps
- 1Write a program that shows
I am learning JavaScript!in the console.
Write it in script.js. If it asks with prompt(), put the answers in Program input, under the terminal.
Use: console.log
2Expected output
It should show
I am learning JavaScript!
3Hints
Stuck? Open one hint at a time: each gives a bit more help.
Hint 1
It's one console.log line.
Hint 2
The words go in quotes inside the brackets, like console.log("…");
Hint 3
Check the dot between console and log, and the closing ) and ;.