alert("hello");
var d = Date();
//alert(d);
var currHour = d.getHours();
document.write(currHour);
function display1(currHour) {
if(currHour > 1) {
alert("good morning");
} else {
alert("ok bye" + currHour);
}
}
The hello alert shows fine, date also shows fine, however currHour is undefined i don’t know
what am I doing wrong here.
Thanks.
You are missing the
newkeyword. new [MDN]Example