Whats wrong with my code?lesson 11


Replace this line with your code. 

var nameString = function (name) {

return("Hi,I am"+" "+ name);	


I mean, are you getting an error message?


it says" it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie."


Hi first you should put


inside a console.log() the the string you should print is

return "Hi, I am" + " " + name

instead of

return "Hi,I am"+" "+ name

no need of () around your string.


var nameString = function (name) {

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

it says error

you should put 

inside a console.log()....

look well what I said

and not the string


@jay8978 Since you went through the trouble of writing a function, you should print the output of your function rather than rewriting the sentence (double the work; be lazier! :slight_smile: ). (Also note that the variable name can't be seen outside of the function's brackets, or "scope".)


console.log( nameString("Susie") );
var nameString = function (name) {

return "Hi,I am"+" "+"name";

i tried everything :frowning:


@jay8978 Don't give up now, you are so close! In this case the problem is that the call needs to be below the function (move it to the bottom).

Later you may see ones that look like

function nameString(name) {

I think these you can call before and after where they are written, but if it looks like var = function... it can only be called after.


One more thing, you want to print the value of your variable, not "name", right? :slight_smile:


omg i got it

var nameString = function (name) {

return "Hi, I am"+" "+name;


Congrats @jay8978 :slight_smile: I knew you could do it! Keep it up! :raised_hands:


@jay8978 Oop, sorry; maybe I misread the program the first time, because I just realized, does it print? This reminds me of your previous question actually. For future reference, I think the aim of the exercise is to try calling your function and printing it at the same time like this: console.log(functionName(argument));.


yep youre right! heres the right code!!! @msfrisby
var nameString = function (name) {

return "Hi, I am"+" "+name;


You got it, @jay8978! :clap::clap::clap: Bonus question: do you see any repetition that can be eliminated?


nameString("Susie") right!


Yes! A winner is you! :raised_hands::tada: