Question about for loops!


Hi, this is the last exercise for loops. I was just wondering why in the output it only displays the number 10 in the for loop instead of 1-10. The editor accepted the code, i was just wondering why it didn’t print out all 10 numbers.

for (i = 0; i < 10; i ++); {
    console.log("The number is " + i);

condition = false
do {
    console.log("Well hello there");
while (condition);
condition = false


The problem is the semicolon ; after your for loop declaration:

The Javascript interpreter reads this as:

for (i = 0; i < 10; i++)

Which just means: Loop and do nothing inside the loop.

If you just remove this, it should work.


thanks! that makes a lot of sense now.