11. Can't see it!? "Oops, try again. Hmm, it looks like your nameString() function doesn't return 'Hi, I am Susie' for the name Susie."

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Lesson 11. Function recap

<In what way does your code behave incorrectly? Include ALL error messages.>
Getting this error, but it does print, Hi, i am **** , also see upload. What am i supposed to do? I am clueless atm. Thanks.

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

var nameString = function (name) {
	return "hi,i am" + " " + name;
};

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

1 Like

Hi the string should be…

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

instead of

"hi,i am" + " " + name;
2 Likes

Hey, I tried your code and made a little modification and it worked.
Check it out. Try this.

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

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

1 Like

Same error, how ever Cynthiarose’s solution worked. It looks like i just should have copied from the instructions. Thanks you both.

2 Likes

You are welcome. Glad my code worked.

1 Like

Thank you, other contributors. My problem was similar, but not exactly the same. The code wouldn’t pass the test until it had BOTH a console.log() output and a return() output.

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

HI if you need help you should post your code…

1 Like

I just did, in separate thread. It lets me pass the lesson, but it’s clearly not working…

2 Likes

Thanks for your code, but I’ve got a question.
Why does A work instead of B? Thanks!
A. console.log(nameString(“Al.”));
B. console.log{nameString(“Al.”)};

2 Likes

Sorry, I’m not much of an expert in JavaScript and I don’t really know why B doesn’t work and A does.:frowning: But I think it’s because we use {} mostly for code blocks and functions, right??

1 Like

because in (nameString(“Al.”)); you have two closings one is for (nameString) which has a opening and closing and the other set is for (“Al.”) if you do (NameString(“al.”)} you will be leaving nameString open as you are closing only the (“Al.”) and not adding the ) that closes nameString so you would have nameString open and close the function when nameString needs to be closed also.

i just don’t know how did you do?i likes the same form,what the diffierent between
them?when i copy it ,it works!

I wrote it wrong by mistake and it passed anyway Lol

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

}

nameString(console.log(“Daniel.”))

It returns this:
Daniel.
“Hi, I am undefined”

I did it by mistake but It passed anyway, maybe the lesson needs to give an error in case that happens.
I fixed it to

console.log(nameString(“Daniel.”))

But the lesson passed Ok with the error.
:stuck_out_tongue:

@1233210000abc The curly brackets are for the JavaScript code and the parenthesis are for the name of the functions and parameters (If I understand correctly).

You will see the that what’s between curly brackets is the JavaScript code that runs when the function is called.

At least that’s what I am understanding at this moment.
Hope it helps

:slight_smile:

I think the check is only looking for a specific way to write the function and not accounting for other solutions.
Believe the “return” in the instructions is how you are supposed to identify it. See below

var nameString = function (name) {
	
// 	console.log('Hi, I am' + ' ' + name); Works but doesn't count in this setting
    return "Hi, I am" + " " + name;
};
console.log(nameString('Susie'));

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.