Try it out!


whenever I run my code, I always get an error message that says, " Oops, try again. Your code caused the following error: TypeError: olderAge is not a function. (In ‘olderAge(michael,nicole)’, ‘olderAge’ is undefined)"

// Our person constructor
function Person (name, age) { = 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

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

console.log("The older person is " + olderAge(alice, bob));
var olderAge = function(person1, person2) {
   if(person1.age > person2.age) {
     return person1.age;  
   else {



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

you call the olderAge function before defining it, that will throw an error


Thank you! I cannot believe that I missed something that obvious!