Stuck at Functions Recap Lesson 11: nameString

I’m hoping someone can help me with this one. the instructions are:
Write a function called nameString() It should take name as a parameter.The function returns a string equal to “Hi, I am” + " " + name. Call nameString() by passing it your name, and use console.log to print the output.
So far I’ve used function to code for numbers, not for text. I have no idea how to code this to “return” a text string. Can someone help?
Codecademy admins: It would be GREAT if there was a “solution” button added so a student could see the proper code and move on! Otherwise we are stuck forever!
thanks, Nina

your code should look something like:

var nameString = function(name) {
    ///then inside your function you input what the instructions are telling you
    return  "Hi, I am" + " " + name ///in order to "return" something you simply type return
}; ///then you close the function here

nameString("Your name"); ///and you call the function here.

Anything you put inside " " will come out as a string of text

Hope this helps if you have any other questions on this feel free to ask

Hi Vince,
thanks for your reply! that is the code I used, but it still gives an error. Apparently this is a common problem as there is a whole page of discussions with the same problem with this lesson:

here is the exact code I used:

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

the error I get is "
Oops, try again. Hmm, it looks like your nameString() function doesn’t return ‘Hi, I am Susie’ for the name Susie."

although the phrase “Hi I am Susie” is appearing in the results box.

Thanks again for your time!

put a comma after high

return "Hi, ///the comma here is necessary/// I am" + " " + name;

there are often times when the instructions tell you to put a certain string into your code and if you don’t put it in exactly as the instructions want you to then the lesson program won’t accept your code. It often sucks but that is just the way the lessons are coded.

Good luck and keep coding

1 Like

Remember when you write nameString to call your name, put the quotes like:


i got stuck like 30 minutes just because i dont remember to put the quotes to a string :frowning:


i think you forgot to add the console.log(nameString); under the nameString call function

because i did the same answer but it keeps asking me about to add the console.log so when i added console.log below the nameString it works the only thing is my console showed [Function] and i think it’s weird but it works.

Well seeing [Function] when using console.log(nameString); is what you should see as nameString is the name of the function. What you should do instead is to console.log the function call e.g.


which should now print the correct output message.

1 Like

Turned out the code i used was fine, but I hadn’t put the comma into the string so it returned an error b/c that is not the exact string it was looking for.
So it’s important to proofread the non-code parts of the lesson as well, I guess!

Thanks for this. I just realized that my problem was that I had included a period in my code block after name.

my code looked like this:

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

console.log (nameString(“Jane”))

I realized my mistake after reading this forum. Thanks!

Hey there, I tried, didn’t work:

var nameString = function (name) {
return “Hi, I am” + “” + name; // also tried +name without semicolon, no use


The error alert is also “Oops, try again. Hmm, it looks like your nameString() function doesn’t return ‘Hi, I am Susie’ for the name Susie.” Is there some bug?

Same, every time i try even though it displays “Hi, I am Sebastian” it says that it needs to say “Hi, I am Susie” but even when i put it with Susie it either doesn’t work and puts the same error or it says to put “Hi, I am Bobby”
Please help
This is my exact code which does display the message I put but still wants me to put Susie instead:

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

console.log (nameString(“Sebastian”));

@bytejumper40712 and @thekyszerkoder no it’s not a bug and it’s not about Susie, it’s just that the author runs some test cases and e.g. tries if

nameString("Susie") === expectedResult

is true and in your cases it is not therefore the error. But although you get the same error there are different reasons:
@bytejumper40712 Your problem is that you didn’t add a space but just an empty string:

" " instead of ""

Also the the task to call the function can print the result can be done in one step so this is fine:


no need for the line before it. Or if you really want this to be 2 statements:

var message = nameString("Jane");

@thekyszerkoder Your problem is that you hard code “Sebastian” in the output message so of course it works when the input is Sebastian but if the input is “Susie” you’d still get “Hi, I am Sebastian”. So maybe have a look at @bytejumper40712 code to see how to use parameters or take a step back and review a previous exercise on this topic.

1 Like

Thanks a bunch, it worked.