<title> Greeting </title>
alert ("Hello, "+ who + '' + who2);
var who = prompt ("what is your first name");
var who2 = prompt ("what is your last name");
alert("Hello " + who + ' ' + who2);
It does not do the same thing.
You NEVER call the function, so it does nothing!
Functions are good for helping you reuse code blocks that do specific tasks without having to write the code again and again, you just call a function and the interpreter then fetches that code block, runs it and the output is then generated if any output is needed, etc.
Functions are your friend :)