+ 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 } }
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.
0
thanks >= 0 is perfect! now it works. i thought <= 0 would stop the loop but my brain was working backwards.