0
JavaScript pro question: Noon or MidnightâŚ
Dear All, for this question, why we need to use âconsole.log(x)â at the end instead of âdocument.write(x)â? Many thanks! function main() { var hour = parseInt(readLine(), 10); // Your code goes here x = (0<=hour&&hour<=12)?"am":"pm"; console.log(x) }
3 Answers
+ 1
YANG Fei
We write console.log for debugging purpose which print anything on browser's console.
document.write used to show output on browser.
+ 2
In addition one thing. It should be written:
var x = âŚ
This code is easy and very short, so the compiler added that for you and it works.
0
Hey Yang
Kavya
Kindly pls
Contact me at
suvarnapatil19085@gmail.com
I want some guidance from you