Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Your First Program · Lesson 7 of 15

Comments

A free lesson from Swipe Coding · JavaScript, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Notes to your future self are one of the most underrated tools in coding. 📝

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;
Everything after // on a line is a single-line comment — the engine skips right over it.

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 start with /* and end with */ — everything between them is ignored, no matter how many lines it spans.
🤖
Commenting out code is basically a pause button, not a delete button. ⏸️

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.

Fill in the blank

A single-line comment in JavaScript starts with ____.

Quick check

Which symbols mark the start and end of a multi-line comment in JavaScript?

True or false

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.

Chapter quiz

Your First Program

10 questions · pass with 60% — just like in the app.

Quick check

Which HTML tag is used to add JavaScript to a web page?

Fill in the blank

To link an external JavaScript file, you add a src attribute to a ____ tag.

True or false

Every modern browser has a built-in JavaScript engine, so no extra installation is needed to run JavaScript on a webpage.

Quick check

Which function is most commonly used to print messages to the browser console?

True or false

You can type and run JavaScript directly inside the Console tab of Developer Tools.

Fill in the blank

The browser panel used to inspect and debug a web page is called ____.

Quick check

What does console.log("Hello, World!") print?

Fill in the blank

Text values like "Hello, World!" must be wrapped in matching ____ marks.

Quick check

Which symbols mark the start and end of a multi-line comment?

True or false

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 →