Tying it All together, Syntax errors


In this section on Javascript Functions, we are supposed to correct the syntax of this poorly written greeting function.
I cant seem to get it correct nor can I write a line of code to pass anything through the function. I will attempt to past my code here and would appreciate any input. Thanks.

var greeting = func (name){
console.log("Hello" + "" +"name");



You will have to use the function keyword......


var greeting = function (name){ //func must be writen as -function-
console.log("Hello" + " " + name);
//console.log prints:
//"Hello" - 5 characters
//+ " " - 1 space (takes 1 space as if it is 1 character
//+ name - it doesn't need quote, it's a parameter, try with and without and you'll see the difference
greeting("Andrew"); //calling the function, name parameter is Andrew

Hope it helps!


Thanks for the explanation !!!


Hi ikustom,
I did write
var greeting = function (name)
{console.log("Hello" + " " + name);

But the code bit rendered as Hello name. It didn't pass my name through.What do you think happened?


Yes, difference is in -"name"- and -name- if you look closer