0

Could anyone please help me out with this one?

Write a program-timer, that will take the count of seconds as input and output to the console all the seconds until timer stops. function main() { var seconds = parseInt(readLine(), 10) // Your code here var i = 0; while(i <= seconds){ console.log(i); i++; } } Sololear output is 6,5,4,3,2,1,0. My output is 0,1,2,3,4,5,6.

8th Jul 2021, 10:33 PM
Sanchit Bahl
Sanchit Bahl - avatar
2 Antworten
+ 1
you don't need i variable: while (0 <= seconds) { console.log(seconds); seconds--; }
8th Jul 2021, 10:37 PM
visph
visph - avatar
+ 2
while(seconds>=0) { console.log(i) seconds--; }
8th Jul 2021, 10:38 PM
Abhay
Abhay - avatar