0
Where is my execution timed out?
I know that execution timed out means that there is an endless loop but I can’t find where. I’m doing the snail in the well project. Here is my code: function main() { var depth = parseInt(readLine(), 10); var days=0 var x=0 do{ x+7 } while (x<depth){ x-2 days++ } } Thx
2 Respuestas
+ 1
it's either a while loop, or a do..while:
while (cond) {}
or:
do {} while (cond);
the difference is when cond(itional) expression is evaluated ;)
0
Have you figured out why the infite loop is happening ElizabethM ? As visph has said, your syntax is a bit off. I think the the infinite loop is because you're not incrementing x. I.e. You're adding 7 but not saving that new value to x. So you probably want x = x+7, or you could do x += 7.