29/33


#1

I don't know what's wrong can somebody help me
// 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 (person1.age >= person.age){
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

this bit is wrong:

if(person1.age < person2.age){
  return person1.age;
}

what you say here is: if person2 is older then person1, return the age of person1

You have two options here: either return the age of person2 in the if statement, or use > instead of <

Also, else can't check any condition. This:

else (person1.age >= person.age){
    return person2.age;
}

is wrong. else is just else:

else {
    return person2.age;
}

if you want to check another condition (which you don't need to) you would have to use else if, else if can check condition, else can't


#3

Thank You, I appreciate it