(29/33)


#1

My code isn't passing but it's correct. Perhaps there is a glitch.

indent preformatted text by 4 spaces

// 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 < person2) {
return person2.age;
} else {
return person1.age;
}

};

// Let
// 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

As you are comparing the age's in your IF-condition
you will want to change

  if(person1 < person2) {

into

 if(person1.age < person2.age) {

#3

It should be if(person1.age < person2.age) instead of if(person1 < person2).

If you want to compare the age, you actually have to access the age. When you are doing (person1 < person2), then you aren't really comparing their age, you are comparing the Person objects.