3/30 ReferenceError: speak is not defined


#1

Hi,
here is my code, I don"t understand why I see this error message.
Basically, it gives me go to the next level,
But I still want to understand this.

var james = {
job: "programmer",
married: false,
speak: function(mood) {
console.log("Hello, I am feeling" + "" + speak)
}
};

james.speak("great");
james.speak("just okay");


#2

there's an error in your code.

var james = {
job: "programmer",
married: false,
speak: function(mood) { <-------you set mood as your variable.
console.log("Hello, I am feeling" + " " + mood)<----change "speak" to "mood", which is a
undefined variable you've set in your parameter.
}
};

james.speak("great");
james.speak("just okay"); <---both function calls give your variable "mood" a value;
now mood is either "great", or "just okay".