11. function recap


Can you tell me what the problem is here?

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

Referenceerror is: Khadz is not defined.

Code is correct output is displayed twice and an error also shown

Khadiz is a name, so it should be a string


Just put quotes around Khadz.

BEFORE: console.log(nameString(Khadz));

TO: console.log(nameString("Khadz"));

Without the quotes, the system will think that Khadz is a variable --> REFERENCE ERROR: Khadz is not defined

Hopes this helps


having this problem too. can someone help?


please make a new topic, this will give you a template which asks for all the details needed to help. We are not magicians, we can't fix: i have the same problem.


Can someone elaborate on the purpose of adding console.log() again? (What function does it play and why is it needed, aside from the instructions asking for it). Because you can just call nameString() and get the same answer. Thanks!!


console.log() will log something to the console, its also console behavior to log the last value, so now because its the last thing happening, its displayed, but what if you had more code? You needed console.log, otherwise, nothing would log


Ahh I see. Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.