Functions recap #11


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/3?curriculum_id=506324b3a7dffd00020bf661#


The error message reads, "Oops, try again. Your code doesn't look quite right. Click "Stuck? Get a hint!" if you need help!" I really don't understand what I did wrong. I even put it into a syntax checker and it said its all valid code. Please Help!


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

console.log(nameString(john));


#2

Hi this part

console.log(nameString(john));

you should put john as a string with the " " around it


#4

Don't give any space between "Hi, I am" and "+".

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

if any error,then copy & paste this code.
all will be ok.
bye.


#5

what do I do wrong here?


#6

Hi what error do you get?


#7

'I am Susie' is printed twice. Which is even beyond my understanding since I printed 'robert' and it does not say 'susie' anywhere.


#8

try to change the console.log with the return statement


#9

Awesome! That does the trick! Thanks a lot.

I do not understand the differency really? console.log is supposed to print my 'output' but so is the return statement right? What is the difference here?


#10

you could read the diference in that topic
https://www.codecademy.com/forum_questions/518ffbfeb3f05c44fe001395


#11

after nameString("robert") give a semicolon.->->->nameString("robert");

Thank you.


#12

It says "Way to go" but it doesn't look like it is.

What is wrong here?


#13

Hi just put the

nameString("Bogdan")

inside a console.log()
and remove that

console.log(nameString)

#14

Worked.
Thanks, again :wink:


#15


What is wrong in this code? Please help.


#16

HI your string shoudl be

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

#17

But why does it print out [Function]? Isn't what you typed and what he typed the same. Shouldn't it produce the same result?


#18

HI when you get function its because your are printing the name of the function

for example

var hello = function() {
    console.log("Hi");
}

if you print it like that

console.log(hello);

//Output
[Function]

instead of call the function you are printing the function name because it missing the ()... then if you that

console.log(hello());
//Output
Hi

And about the string

look welll his is like that

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

and the one I posted ...

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

Do you see the difference?


#19

Thanks! that helped.


#20

Hi guys!

Can someone point what's happening?
Seriously, why this FS is not working :blush:?

I'm trying to not hate JavaScript. Please help me :)!

Thanks a lot!


#21

Hi try to refresh the code..