Reference error


nameString = function(name) {
return "Hi, I am" + " " + name

Why is this not working?


You need a semi colon after this statement. ;


You should pass name as string, so it should be in quotation marks:


Also, console.log(nameString) will print function body, if you want to print result of function call, use



And these two lines?? You cannot console.log a function


thank you :grinning:


You're welcome. Check my edited post :slight_smile:


Actually, you can console.log() a function. It will print it's body.

var cube = function(n) {
    return n * n * n;

// => 125
/* => function(n) {
    return n * n * n;


What he was trying to do was not console.log the body of the function. The logic behind his code was by console.log'ing
nameString it would also include spaghetti as if nameString was a variable. :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.