Browser (safari and chrome) hangs(has been 2 days now) when clicked on "save&submit", lesson-introduction to 'for' LOOPS in JS, 5th topic


#1


Replace this line with your code.


#2

@g.divya2151,
Please give us the FULL code you are using....


#3

// Edit this for loop!

for (var i = 0; i < 35; i+5) {
console.log(i);
}


#4

Did you mean to write,

i += 5

?


#5

Yes, Thank you
I found out the loop never ends if i do i+5, i tried i+=5 then and it worked. Thank you

One question though, in C and C++, i+5 would have worked, so is this a syntax difference in for loops between C++ and JS?


#6

In JavaScript, i + 5 is an expression. It needs to be assigned. i += 5 is an assignment. It's not unique to JS, but expect other syntax differences between the two languages.


#7

A post was split to a new topic: What is wrong with my code?


#8

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