JavaScript Comments — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Comments lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Add a line comment
easy10 minExplain the line with a // comment, then show "documented".
- 2
Use a block comment
easy10 minAdd a /* */ comment above the code, then show "blocked".
- 3
Comment out a line
easy10 minDisable the wrong line with a comment so "correct" is shown.
- 4
Comment at the end of a line
easy10 minAdd a trailing comment after the statement.
- 5
Keep code readable
medium10 minExplain a calculation with a comment and show "clear".
Find the bug(5)
- 1
Fix the unclosed block comment
easy8 minThe block comment never closes, so the real code is swallowed.
- 2
Fix the commented-out code
easy8 minThe working line was accidentally commented out.
- 3
Fix the wrong comment marker
easy8 minA hash is not a JavaScript comment.
- 4
Fix the comment that hides half a line
easy8 minThe comment starts too early and disables the assignment.
- 5
Fix the nested block comment
easy8 minBlock comments cannot nest, so this breaks.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace