0

Anytime I execute this code,it says execution timed out..can anyone help please??

function main() { var depth = parseInt(readLine(), 10); //your code goes here var day= 1; var n=5; var o=n+5; do{ console.log(day);n+5;day++; if(o>=depth){ break; } } while(o<=depth); }

19th Nov 2021, 2:21 PM
abena odai
abena odai - avatar
4 Respuestas
+ 3
o never changes so the loop keeps running infinitely
19th Nov 2021, 4:18 PM
Lisa
Lisa - avatar
+ 1
The o variables never changes in the loop, so o > depth is never true. Therefore, you never break from the while loop
19th Nov 2021, 8:45 PM
Lisa
Lisa - avatar
0
I did change it,day++ Or?
19th Nov 2021, 8:42 PM
abena odai
abena odai - avatar
0
Okay I get it now, thank you.
19th Nov 2021, 9:45 PM
abena odai
abena odai - avatar