Functions recap problem


#1

My code is this:

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

and instead of it printing "Hi, I am Logan" it is printing this: [Function]
What's going on???


#2

Hey Logan,

On line 2 you missed the return statement and the nameString on line 3 needs to be inside your console.log

The final working code should look something like this:

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

};
console.log(nameString("Logan"))

#3

Hello I have another problem on same topic..Check image

Here i also tried to change my name "Rushabh" to "Susie" but same problem..

Thanks ..


#5

Thanks for the help, I was not understanding.


#6

there was no mention of "Susie" in the instructions


#7

This has nothing to do with using "Susie". What happens is that the author wrote a few test cases to confirm that your code is working correctly and the first one is to check your code by running nameString("Susie") and inspecting the output and if it doesn't match the expected output of "Hi, I am Susie" you get the error message. So the problem is not your input being "Rushabh" but the output being not "Hi, I am Rushabh". As far as I can see you used both options to add a space which leads to 2 spaces between "am" and "Rushabh" instead of one and that is all it is complaining about. Hope this make it clear.


#8

Oh.. I see ..
Got it Thanks.. :relieved: