Time’s up! Challenge need help JavaScript. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Time’s up! Challenge need help JavaScript.

I have this code but it’s not giving a output what do I do wrong? function main() { var seconds = parseInt(readLine(), 10) // Your code here while (seconds <=0) { //the var of the challenge until 0 or lower console.log(seconds); //print the seconds to console seconds--; //after every print -1 } }

16th Jan 2021, 10:23 PM
Martijn Greven
2 Answers
+ 5
Wrong condition. Should be while (seconds >=0). Whatever you enter, if it's greater than 0, it will fail your check on the first try and never execute the code inside the loop.
16th Jan 2021, 10:47 PM
Mateusz Malenta
Mateusz Malenta - avatar
0
thanks >= 0 is perfect! now it works. i thought <= 0 would stop the loop but my brain was working backwards.
16th Jan 2021, 10:51 PM
Martijn Greven