Where did I get the infinity?

0 like 0 dislike
4 views
Good day to all.

Prompt because of what there is here an infinite loop and how to fix it:

var m_1 = 0 while (m_1 <= 10){ if (m_1 === 3){ continue; } console.log (m_1+1) m_1 = m_1 + 1 }


Thanks in advance!
by | 4 views

2 Answers

0 like 0 dislike
var m_1 = 0

while (m_1 <= 10){
if (m_1 === 3){
m_1 = m_1 + 1; // you forgot to change the value and it "froze" on 3
continue;
}
console.log (m_1+1)
m_1 = m_1 + 1
}
by
0 like 0 dislike
The case when is better to use for when you need to protonirovanie a certain number of times.
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
110,608 questions
257,186 answers
0 comments
33,851 users