Comments
A free lesson from Swipe Coding · JavaScript, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
A comment is a note written directly in your code that the JavaScript engine completely ignores when it runs. Comments exist purely for people — to explain what a piece of code does, why it's written a certain way, or to leave yourself a reminder.
// This line calculates the total price let total = price * quantity;
That's a single-line comment, made with two forward slashes (//). Everything from // to the end of that line is ignored. For longer notes, or for text that spans several lines, JavaScript also has multi-line comments, which start with /* and end with */.
/* This function calculates a discount. It takes the original price and a percentage off. */
Multi-line comments are also handy for temporarily disabling a block of code without deleting it — a trick often called "commenting out" code — which is useful while you're testing or debugging.
A single-line comment in JavaScript starts with ____.
Which symbols mark the start and end of a multi-line comment in JavaScript?
The JavaScript engine executes the text inside comments as part of the program.
Good comments explain why code exists or why a choice was made, not just what it does — code that simply restates the obvious ("// add one to x") tends to clutter a file rather than help anyone reading it.
Your First Program
10 questions · pass with 60% — just like in the app.
Which HTML tag is used to add JavaScript to a web page?
To link an external JavaScript file, you add a src attribute to a ____ tag.
Every modern browser has a built-in JavaScript engine, so no extra installation is needed to run JavaScript on a webpage.
Which function is most commonly used to print messages to the browser console?
You can type and run JavaScript directly inside the Console tab of Developer Tools.
The browser panel used to inspect and debug a web page is called ____.
What does console.log("Hello, World!") print?
Text values like "Hello, World!" must be wrapped in matching ____ marks.
Which symbols mark the start and end of a multi-line comment?
The JavaScript engine executes the text inside comments as part of the program.
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 →