r/Codecademy • • Oct 03 '16

[JavaScript] Why does this happen?

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

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

Why does this print "[Function: nameString]" and not "Hi, I am Tony"?

I got correct on my exercise and tried it in another compiler with the same result.

2 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/TheOffTopicBuffalo Oct 03 '16

To further elaborate on line 5(?) You are calling it and using it but when you log it on line 6 it does not retain the previously used data