Glitch with Introduction to Functions in JS lesson 11


#1

I keep getting this error:

Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie.

But this is the code I used:

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

nameString("John");

I did not put the name Susie in yet it is in the response.

Here is the output:

Hi, I am John
Hi, I am Susie

Does anyone else have this problem or know why it is occurring?


#2

The problem in your code is this line:

return console.log("Hi, I am" + " " + name );

the test function expects that your function returns "Hi, I am x" for an input of x but your function returns undefined because that is the value of console.log. Yes it also, as a side effect, prints this statement to the screen. But that is something you should do outside of the function, the function itself should just return something.

BTW: the Susie case is just one of the test that is run after you press submit to see if this is working.