29. Try it Out!


#1

Hello, I am struggling with the code in ' ' ', can someone help?

https://www.codecademy.com/en/courses/spencer-sandbox/4/4?curriculum_id=506324b3a7dffd00020bf661#

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

please use markup:

This makes your code much more readable. Why do you post in community? Why not on the introduction to objects 1? the track this exercise is part of

here:

if (person1.age > person2.age);

the semi-colon interrupts the if statement


#3

Wow, thanks for the feedback! I will do that from now on.

I revised the code and it is still not working:

var olderAge = function(person1, person2) {
if (person1.age > person2.age); {
return person1.age;
} else {
return person2.age;
}
};


#4

the semi-colon is still there? I only showed the line where the invalid semi-colon is


#5

Oh my gosh, I took out the wrong one. Thank you so much!


#6