Question on lesson 11. Function recap


#1

I'm confused.
This

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

nameString ("joel")

Shows txt in the console, and completes the objective but the lesson is not complete.

while this

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

nameString ("joel")

this completes the lesson objective, but seems to have an extra log in the console with my name.

can anyone explain why the first script is wrong?


#2

I don't understand why you put:

//This
console.log ("joel")
//Or This
console.log ("name")

As neither will run as a result of the function.


#3

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

};

nameString ("joel")

this was my first shot which got the log in the console "Hi, I am joel"

but it still wasn't correct


#4

You've forgotten ending semicolons, the parenthesis needs to be touching the function call, and function declaration, and please format your code.


#5

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


nameString("joel")

Sorry about the format...

is this correct to what you are saying?

once again it doesn't pass the criteria.

I am still confused why this passes the lesson?

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

};
console.log("joel")

nameString("joel")

and the top script doesn't


#6

The only difference is this line in the second one:

console.log("joel")

Maybe log the name in your function?


#7

Well i did this and it works as well...

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

console.log (nameString("joel"))

i think this may be what they were looking for...


#8

Not a deal breaker.

Have you tested this assertion? JavaScript doesn't care about white space.


#9

Or nothing at all. The function should not contain a console.log() statement, and as it is written after the return, it is unreachable by any accounts.