0

Help for 19.2 JavaScript

Hello guys, I need help for my code. I was trying to do the practice 19.2 of the JavaScript Course, but I’m stuck in there. I have a solution but it won’t work. Can you help me? Here is my solution: function main() { var seconds = parseInt(readLine(), 10); while(seconds>=0){ document.write(seconds+"</br>"); seconds--; } Im would welcome your response. Hendrik

26th Nov 2021, 10:24 AM
Hendrik Nordenholt
9 odpowiedzi
+ 2
Hendrik Nordenholt while(seconds >= 0) { console.log(seconds) seconds--; }
26th Nov 2021, 12:18 PM
zexu knub
zexu knub - avatar
0
use console log for output & don't include html break line tag.
26th Nov 2021, 10:46 AM
zexu knub
zexu knub - avatar
0
Write a program-timer, that will take the count of seconds as input and output to the console all the seconds until timer stops. This is the task. And thanks for the answer. I will try it
26th Nov 2021, 12:12 PM
Hendrik Nordenholt
0
I tried the solution of zexu knub and it didnt work. Do you have an other solution ?
26th Nov 2021, 12:15 PM
Hendrik Nordenholt
0
Hendrik Nordenholt Add a semicolon in the first statement of zexu knub 's code and it'll work.
26th Nov 2021, 2:45 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
0
Arun Ruban SJ it will work even without semicolon.
26th Nov 2021, 3:12 PM
zexu knub
zexu knub - avatar
0
zexu knub Thank you, I didn't know about this in javascript. Does every statement works without semicolon or just the console??
26th Nov 2021, 3:24 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
0
Arun Ruban SJ Mostly, JS have Automatic Semicolon Insertion ( ASI ). which Insert a semicolon automatically even when you don't write manually.
26th Nov 2021, 3:29 PM
zexu knub
zexu knub - avatar
0
Ok thanks
26th Nov 2021, 3:32 PM
Arun Ruban SJ
Arun Ruban SJ - avatar