Functions Recap printing correctly, but getting error


#1



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


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


#2

Put a space between your quotation marks.. What's the error?


#3

OK.... i did that and refreshed the page and it prints perfectly now, but not getting the green light...?


#4

You need to have the console.log outside the function

So after


#5

now it's not printing the "I am Greg..." it's printing "Function"


#6

Show me your updated code


#7

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

};
nameString("Greg");
console.log(nameString);


#8

This lesson is looking for the exact working
return "Hi, I am" + " " + name;

so change hi to Hi


#9

still printing "function"...

and now it's saying that I've completed it correctly, even though it's printing "function"?

do i need console.log(nameString) inside and outside of the function?


#10

This is correct, refresh your page and try again or reset lesson and paste in.

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

};
nameString("Greg");
console.log(nameString);

#11

i refreshed and reset code and copy/pasted as you suggested the exact code as you've written and it's still printing "function" but i've got the green light..so, i'm going to go with as long as i know the code is correct!
Thank you for your help..

Is this the way coding is? constant debugging and trying new angles?

it's a bit difficult when you don't if it's you or the program you are using that's not working properly..


#12

Yes programming requires debugging, trying and testing,

Two issue's you experienced one was Codecademy's strict SCT(exact text) and the other was that the error was stored and only disappeared after a refresh.

printing "function"
I'm sorry not paying close attention what you need to do is call:

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

#13

Thanks for that...am i calling that last bit of code you sent in the function only?


#14

Out of the function..

What it's doing is setting the name and calling it


#15

Ok, thank you again...