What is wrong?


#1

IT'S OK I HAVE SOLVED IT

What am i missing? I can't find any errors. p.s i already refreshed the browser 4 times.

Error msg: SyntaxError: Unexpected number '2'. Expected a ')' or a ',' after a parameter declaration.

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

Person 2 or person2?


#3

yeah i just figured my mistake out, thanks though :smiley:


#4

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