-4

Just trying to get a better understanding of a JavaScript For loop. I know what the output will be, which is 0-9:

var i;
for (i = 0; i < 10; i++) {
    document.getElementById("demo").innerHTML += i + "<br>";
}

But what does innerHTML += i mean in my script? More specifically, what does the += do, and what does it mean?

jean-max
  • 1,640
  • 1
  • 18
  • 33
AB10
  • 1,003
  • 2
  • 14
  • 19

1 Answers1

0

It means "add to the current value".

The example you give, will take the current innerHTML and add 10 <br> tags to it.

Nimesco
  • 688
  • 4
  • 13