Intro to function: "nameString function doesn't work" What have I done wrong?


#1

This function is supposed to print "Hi, I am Khadz", but when I run it, I get back this error message:

Oops, try again. Your code doesn't look quite right.

What have I overlooked or did wrong?

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


#2

Hello,

problem is in the function call:

nameString(Khadz)

The computer does not know what the Khadz is. It's not a primivtive type (like 12.5, 'Hi' etc.) and variable called Khadz is not defined.


You were supposed to pass a string as a parameter (nameString('Khadz')).


#3

Thank you! It's the little things that still count -- I missed the quotation marks. Thanks again :slight_smile:


#4

You're very welcome :slight_smile:


#5

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