29.Try it out!


#1

SyntaxError: missing before statement

// Our person constructor
var Person=function (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 "same age";
    }
    else if (Person1.age>Person2.age)
    {
        return Person1.age"older";
    }
    else 
    {
        return Person2.age"older";
    }
    
};

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

try this:

return Person1.age -= Person2.age;

Also make sure that you're returning the sentences that the exercise tells you to.


#3

It worked out ! thanks for your reply


#4

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