Function Recap issue


#1

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

I'm really stuck on what i'm doing wrong here.


#2

the console.log after the return statement can never be reached as you leave the function on return. What is the error message about this?


#3

Oops, try again. It looks like you didn't print anything to the console! Did you remember to console.log() the result of passing your name to the nameString() function?


#4

Ok well in this case get rid of the console.log inside of the function as it is as said pointless and wrap your function call in a console.log:

console.log(nameString("Dan"));


#5

so is the "Hi, I am" + " " + name; part nowhere in the answer? does step 3 just lay out an assumption?


#6

What do you mean with this?


#7

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

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

this should work


#8

Please do not post solutions. This exercises should be doable and if not mention why instead of spoiling them. Rather give hints or short snippets that explain the problem and how to solve it. Also if you post code please format it in a readable way. Backticks before and after it for inline code or 3 backtics before and after for syntax highlighting or 4 spaces for indented blocks. Also marking your code and using CTRL+SHIFT+C works (maybe add a blank line to top and bottom if necessary).

Last but not least when you execute it like this:

nameString("Dan")
console.log(nameString);

the value of nameString("Dan") triggers one signal that lets you pass but the value you compute here is never used. And console.log(nameString); prints the function name which means that you'll see something like [Function] which is correct as it is a function but is probably not what you wanted to see. So better use:

console.log(nameString("Dan"));

as explained above. Thank you.