Function Name(){} vs var name =function (){}


why codecademy writes function like this

var greeting = function (parameter) {
console.log("Great to see you," + " " + name);

why not like this

function greeting (parameter) {
document.write("Great to see you," + " " + name);


Because Douglas Crockford would have a fit you used document.write.


Well in this track your operating with the console and not the web page so document.write should not be the tool of choice and as far as I know it's considered a bad habit anyway :slightly_smiling:

About the difference of functions:
A google search yields this explanation:

and many others. Afaik you're allowed to use both ways in the course maybe the author doesn't want to confuse with two ways of writing a function or with the concept that this is possible:

function greeting (name)  {
    console.log("Great to see you," + " " + name);

although it might not be intuitive to use something before you have it. Idk.