11. Functions Recap


#1

okay so I worked out the code, and It worked and had a way to go sign at the bottom of the screen, but rather than printing the string, "Hi, my name is ____" it just prints
[Function]
why is this?
heres my code:

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

nameString("Emily")
console.log(nameString)

And an image of the code itsef:

Thanks x


#2
nameString("Emily")
console.log(nameString)

The first line calls your function and therefor has a value of "Hi, I am Emily" which is never again used (would've been great if you'd console.loged this one) and the next line is just console.logging the function name and therefor it tells you correct that this is a [Function]. As said rather delete this line and console.log the line before.


#3

oh I get it now. Thanks alot for the help :smile: :+1:


#4

I found out how to print the full sentence:

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

console.log(newName)