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) }
2 Answers
+ 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.
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