Why does this loop?


#1


It crashes my browser and i'd like to know why


for (var k = 0; k < 9; k+2); {
    console.log(k);
}


#2

for (var k = 0; k < 9; k += 2) {
    console.log(k);
};

It's not working because you need to use the += operator to increment by 2, not "k+2." There also shouldn't be a semicolon after the conditions.


#3

Right fixed it, Thank you very much!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.