Please help 29/33


#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
var olderAge = function(person1, person2) {
if (person1.age <= person2.age) {
return person1;
}
else (person1.age >= person2.age) {
return person1;
}

};

// Let's bring back alice and billy to test our new function
var person1 = new Person("Alice", 30);
var person2 = new Person("Billy", 25);

console.log("The older person is " + olderAge(Alice, Billy));


#2

the problem I see here is that return person1 should actually be return person2.age;

for this, it should be return person1.age;

also for my code,

is actually lower cased, not sure if it makes a difference.

Heres my code;

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


#3

var olderAge = function(person1, person2){
if ( person1.age > person2.age){
return person1.age;
}else if (person1.age < person2.age){
return person2.age;
}else if (person1.age === person2.age){
return person1.age;
}
}
hope this works for you
lastly, i returned person 1 because either way person1 & preson2 are equal.