Error completing lesson


#1

Hello.

I'm either having a brain freeze or there's a bug. Been doing well up to now but cannot get past this lesson.

Please advise:

=====================

(Lesson)
Take a look at the partially-defined james object. Complete the speak method such that the last two lines in the editor will cause "Hello, I am feeling great" and "Hello, I am feeling just okay" to be printed to the console.

var james = {
job: "programmer",
married: false,
speak: function( ) {

}

};

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

======================

==> I'm putting in follow but getting error:
"It looks like your speak method doesn't properly take in a single argument and output the correct string."

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

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


#2

The this in your console.log isn't needed.


#3

Hello.

Thanks for reply. I originally had the following console.log and it produced the correct output, but still got the following error and won't complete the lesson:

console.log("Hello I am feeling " + mood);

(error)
It looks like your speak method doesn't properly take in a single argument and output the correct string.


#4

Add extra space (" ") in front of mood:+ " " + mood


#5

Thanks. Syntactically, there's nothing wrong with console.log("Hello I am feeling " + mood); though is there?


#6

I understand what you said. I did it exactly like you at first, but I finally found out the editor is sensitive with an extra space. So, it works for me with an extra space; try it either " mood" or " " +mood.


#7

Thanks for reply. I already did try and it worked.


#8

I have found that, the text in the instructions is precise.... so if/ when I mistype the text I get errors. Now I cut and paste the text from the instructions.


#9

I generally do the same :grin:


#10

@firstcoder007 can you also have this for a solution.
`var james = {
job: "programmer",
married: false,
speak: function(mood) {
if(this.mood == great){
return "Hello, I am feeling great";
}
else if (this.mood == okay) {
return "Hello, I am feeling just okay";
}

}

};

// james.speak(great);
// james.speak(okay);
console.log(james.speak("great"));
console.log(james.speak("okay"));`