29. Try it out! SyntaxError: expected expression, got ')'


#1


https://www.codecademy.com/en/courses/spencer-sandbox/4/4?curriculum_id=506324b3a7dffd00020bf661#


I feel like I nailed this exercise, but the environment doesn't think so.

I've checked up and down these forums and my code seems to be on point, but it won't let me move on.

Everything I try and run, I get SyntaxError: expected expression, got ')'
Have I missed something? I'm thinking that I mistyped another ) somewhere but I can't find anything.

Thanks


// Our person constructor
function Person (name, age) {
    this.name = name;
    this.age = age;
}

// We can make a function which takes persons as arguments
// This one computes the difference in ages between two people
var ageDifference = function(person1, person2) {
    return person1.age - person2.age;
};

// Make a new function, olderAge, to return the age of
// the older of two people
var olderAge = function(person1, person2) {
    if(person1.age > person2.age) {
       return person1.age;
    }else{
        return person2.age;
        }
);
// Let's bring back alice and billy to test our new function
var alice = new Person("Alice", 30);
var billy = new Person("Billy", 25);

console.log("The older person is " + olderAge(alice, billy));


#2

see the " ) " on the last line? i believe that you wrote closing parenthesis instead of closing curly braket " } "


#3

Argh! Of course! I just KNEW it would be something stupid like that!

Thanks a lot!


#5

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