JavaScript · JS Tutorial · Lesson 6
JS Comments
Single-line and multi-line comments.
Comments explain code and can prevent execution when testing alternatives.
Example
<p id="demo"></p>
<script>
// Single-line comment
let x = 5; // Declare x, give it the value of 5
/*
Multi-line comment:
the code below changes the paragraph
*/
document.getElementById("demo").innerHTML = "x is " + x;
// document.getElementById("demo").innerHTML = "This line will not run";
</script>
Keep reading “JS Comments”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.