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) }

16th Jul 2021, 7:41 PM
YANG Fei
YANG Fei - avatar
3 Respostas
+ 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.
16th Jul 2021, 7:45 PM
A͢J
A͢J - avatar
+ 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.
16th Jul 2021, 8:07 PM
JaScript
JaScript - avatar
0
Hey Yang Kavya Kindly pls Contact me at suvarnapatil19085@gmail.com I want some guidance from you
22nd Jul 2021, 1:19 PM
Rotace
Rotace - avatar