Hello World
A free lesson from Swipe Coding · JavaScript, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
By tradition, the very first program you write in a new language simply prints "Hello, World!" — a small way to confirm everything is set up and working before you move on to anything more complicated. In JavaScript, that program is a single line.
console.log("Hello, World!");You can run this two different ways. Open a browser's Developer Tools, click the Console tab, type the line in, and press Enter to see it run instantly. Or, save it inside a .js file and link it into an HTML page with a <script> tag (or run it with Node.js) so it executes automatically when the page loads.
Notice that "Hello, World!" is wrapped in quotation marks. In JavaScript, text like this is called a string, and it must be wrapped in matching quotes — either single (') or double (") — so the engine knows where the text begins and ends.
In JavaScript, text values like "Hello, World!" must be wrapped in matching ____ marks.
What will console.log("Hello, World!") print?
You can only run a Hello World program by saving it in a file — typing it directly into the browser console doesn't work.
Try changing the message inside the quotes and running it again — Hello World is meant to be experimented with, not just typed once and forgotten.
Keep your streak going in Swipe Coding
Swipe through every level of JavaScript on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →