What am i doing wrong?


#1

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

};
console.log (nameString ("Roman"));
//i am getting an undefined error what am i doing wrong?


#2

i solved my own problem. you can't have return and a space between the code so it would be return"Hi, I am" + " " + name;
not return
"Hi, I am" + " " + name;

can someone please explain why this is?


#3

I don't think it matters if there is the keyword return and the rest of it on the next line. Is that what you mean?


#4

yeah that what i mean but it would say undefined error if i pressed enter then typed the rest on the next line.