Code returns [FUNCTION]


#1



exercise 11


instead of printing 'Danny' it prints '[FUNCTION]'


var nameString = function(name){
    return("Hi, I am" + " " + name);
    console.log(nameString);
};
nameString("Danny");
console.log(nameString)


#2

I am going to change browsers to have a look Firefox to Chrome


#3

The value you printed is a function, look at your code and verify that.
Makes sense that the output says "function" doesn't it?

Perhaps you meant to do something else, but only you can decide that.

Chrome and Firefox should both be fine.


#4

This is why, you are not invoking the function. What you need to do is log the return value of the call expression:

console.log(nameString("Danny"));

#5

@p0st1e64hotmail.com,
With your

console.log(nameString);

you are Displaying the associated-Value of the nameString variable which is a function....

To see the function-definition
you will have to use

console.log( nameString.toString() );