Problem with syntax


#1
var james = {
    job: "programmer",
    married: false,
    speak: function(mood) {
        if (mood = "great") {
            console.log("Hello, I am feeling great")
        } else if (mood = "just okay") {
            console.log("Hello, I am feeling just okay")
        } else {
            console.log("Go away!")
        };
};
};

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

It tells that it misses } after property list. What's wrong?


#2

You only need this:

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

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


#3

First of all, I suggest you put semi colons after your console.logs. Second, I don't really think there's a problem with the brackets, but if there is, I allow you to call me stupid or whatever. But I don't think there's a special problem with it.


#4

Weird without a semicolon it still works


#5

Okay you can call me stupid now. :smiley:


#6

Thx guys for your feedback. The "feeling" thing got the trick done.