When did window.onload become a function? | Codecademy

No, really. Can anyone kindly explain me how this has happened?

Our tutor Chris Danzig writes

3) Within your window.onload() function, create an instance of the Date object using new Date(). See the hint for more details.

FUNCTION???
Shame on MDN and the zillion sites claiming that window.onload is a GLOBAL EVENT HANDLER. You silly… it’s window.onload(), the function!

But the “instructions“ have more to give.
Our tutor did start the exercise with a promising

Wouldn't it be very cool if there was a greeting that changed depending on what time of day it was??

But then… nothing more on the subject. Disappeared.
Not a single, if before noon write “Good morning” else write that.
Maybe he changed his mind half-way? We’ll never know.

Enough? Nope it isn’t.

4) Call the getGreeting() function – passing in the Date object that you constructed.

Cool. Now when we got to the getGreeting() function? Moreover:

What’s the meaning of passing in the Date object (that we have been instructed to construct in the window.onload() function) to the getGreeting() function???

Simply tell us folks to create a function getGreeting() where we’ll have to declare a var = new Date() (and another one to store getHours() if needed).
Seeing that the if condition is gone, then we’ll just have to write the content of the var to <h1 id="greeting"> via innerHTML.
Finally, call getGreeting() via window.onload (not the function one). Or:

function getGreeting (){
now = new Date();
hour = now.getHours();
greet = document.getElementById("greeting");
if (hour<12){
greet.innerHTML = "Good morning! It's " + hour + "am";
} else {
greet.innerHTML = "Good afternoon! It's " + hour + "pm";
}
}

window.onload = getGreeting();

Sadly, the code above is correct but is not accepted.
Instead, this one below is not correct but will make you pass:

function getGreeting(date) {
return "The date is " + date;
}

window.onload = function() {
var today = new Date();
document.getElementById("greeting").innerHTML = getGreeting(today);
};

Finally, some people had to resort to insert the code inside the HTML to pass:

<script type="text/javascript">
var getGreeting = function(){ 

var today = new Date();<--!set date-->
var hours = today.gethours();<--!find hour of day-->

document.getElementById('greeting').innerHTML = hours;<--!set innerHTML to hours-->
};
    window.onload = function(){
    getGreeting();<--!call the above function when window loads-->
    }
</script> 

Someone should really triple-check these exercises prior release.