PrepAway - Latest Free Exam Questions & Answers

What willthe following JavaScript code do when it runs?

What willthe following JavaScript code do when it runs?
<SCRIPT Language=”JavaScript”>
<!–var d=new Date;
var h=d.getHours();
var msg=””;
var targ;
if(h<12)
msg=”<h1>Good Morning!</h1>”;
else if(h>=12 && h<18)
msg=”<h1>Good Afternoon!</h1>”;
else
msg=”<h1>Good Evening!<h1>”;
document.write(msg);
/–>
</SCRIPT>

PrepAway - Latest Free Exam Questions & Answers

A.
It will write “Good Afternoon!’

B.
If it is before noon, it will write “Good Morining!”, if after noon but before 6 pm, “Good
Afternoon!” if after 6 pm, “Good Evening!”

C.
It will write “Good Evening!”

D.
It will write “Good Morning!’


Leave a Reply