Print the age of the older person


#1

Error: Oops, try again. Your olderAge function seems to be returning something other than a number. The function should return the AGE of the older person

function Person (name, age) {
this.name = name;
this.age = age;
}

var ageDifference = function(person1, person2) {
return person1.age - person2.age;
};

var olderAge = function (alice,billy) {
if (alice.age > billy.age) {
console.log(alice.age);
} else {
console.log(billy.age);
}
};

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

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


#2

These need to be person1 and person2, as well as

right here.


#3

Thank you kyleaw.
I wrote console.log instead of return, that was my problem...lol :slight_smile:


#4

Whoops, I didn't even notice that. :slight_smile:


#5

Do you know what is difference between console.log and return?


#6

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