What is wrong with my "Objects 1:- 29- Try it out"


#1

// 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
function olderAge(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

Here's a twist:

return ageDifference(person1, person2) < 0 ? person2.age : person1.age;

I don't really see where the question is, though. Are you getting an error message?


#3

var billy = new Person("Billy", 25);) <---You have  a syntax error here..

Your code should be

var billy = new Person("Billy", 25);