Semicolons separate JavaScript statements. Add a semicolon at the end of each executable statement:
<script>
a = 1;
b = 2;
c = a + b;
document.getElementById("demo1").innerHTML = c;
</script>
When separated by semicolons, multiple statements on one line are allowed:
<script>
a = 1; b = 2; c = a + b;
document.getElementById("demo1").innerHTML = c;
</script>
On the web, you might see examples without semicolons. Ending statements with a semicolon is not required, but it is highly recommended. |