0

Loops Issue

This is the function I made for the Snail in the Well trial on JavaScript. When I console.log(i) I get a number indicating that my function works. But no matter how I try to word my “while” or no matter how I change the area to increase the count, I only get errors or 1 as my answer. The point of the question was how many times does the function have to run before it stops and I just can’t seem to understand what I’m doing wrong. function main() { var depth = parseInt(readLine(), 10); //your code goes here for (i=0; i<=depth; i+=7); i-=2; var count = 0 while (i<depth); count++; console.log(count) }

31st Jan 2021, 5:23 AM
Mark
Mark - avatar
2 ответов
+ 1
Also the hint says to use a break but whenever i attempted to use a break it only gives me errors and says invalid break or something along those lines.
31st Jan 2021, 5:24 AM
Mark
Mark - avatar
0
for( var i=0;i<depth; i++){ if(s>=depth || s>=depth-2 ){ break; } s=s+g-t ; //5//10//15//20//25//30//35//40 These are some necessary changes that you should bring to your code
31st Jan 2021, 5:43 AM
Atul [Inactive]