Literally Speaking


#1


Introduction to Objects 2;Literally Speaking

facing the following 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(sen) {
        console.log("Hello,I am feeling" + sen);
        
    }
};

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


#2

Hi you should add a space between feeling and sen

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

And

the string should be

"Hello, I am feeling"

#3

thank u.didnt realise such a silly mistake


#4

Did it work? cause it's still not working for me...


#5

you can do it like that too guys,by using the power of "this" :slight_smile:

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

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


#6

Though I suppose the following is more efficient since you write less code :slight_smile:

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

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