As I understand it the console.log should be inside the function and it works. But the lesson does not accept until it is outside and then it doesn't work.
Well return is the keyword that a) returns a value to the caller and b) returns to the caller (meaning it exits the function). So using anything after return will just be ignored that is why you're first approach fails. The second one is actually correct and calls the function so the test function is fine with it. What somehow is often misunderstood is that calling the function and printing the value is actually one statement:
var message = nameString("joe"); console.log(message);
But you call the function which returns the value (which is not used anywhere) and then you print the name of the function which tells you the correct but worthless answer that this is a [Function].
Thank you that worked. Can't believe I forgot about it even though it was in the unit before.
The lesson is not so straight forward about this. Thanks for the detailed break down! I was confused and had the exact problem as user gurenmarkv.