Pls help


Replace this line with your code. 

for (var i = 1; i >= 1; i++) { 	console.log(i);


Help with what? You've got to ask for what you want to know. Imagine that you will only get an answer to exactly what you ask. You haven't asked anything, so there would be no answer. If you don't explain what you want then anyone helping would have to guess, it's more effort and it's likely to be something other than you want, a waste of everyone's efforts.


with the code it going into infinite loop after replacing it with this
for (var i = 10; i >= 0; i++) {


That doesn't look like the full code, it's not valid syntax, will not run at all, much less infinitely! It's important that you show exactly what you have!

Assuming that there's a } at the end of that, then yes, that is an infinite loop.
Are you familiar with how a for-loop works? You may want to have a look at this:

When you've read that, or otherwise have a full understanding of what a for-loop does (it's not very complicated, so getting a full understanding of it is very reasonable), then you can start inspecting your loop and ask yourself why it would stop, compare what it says to what you intend it to do.

In particular you'll want to look at what controls whether there is a next loop or not. Since that's what has the potential to make the loop never-ending. What has to happen for that to determine that the loop should stop?

Keep in mind that memorising how something "should" look will do you no good. You will need to reason about and understand why this is an infinite loop.


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