- 1

Why does this for loop not work?

var depth=42; var i=0; var k=0; for (; i<depth; i+7){ k++; if (i>=depth){ break; }else{ i-=2; } } console.log(k)

6th Mar 2021, 10:28 AM
Stas Fe
Stas Fe - avatar
2 Answers
+ 2
Stas Fe , change in the loop => i+= 7 or i = i + 7.
6th Mar 2021, 10:44 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
TheWh¡teCat 🇧🇬 thank you. That's it. I'm so dumb 😅
6th Mar 2021, 11:34 AM
Stas Fe
Stas Fe - avatar