Help stuck 29


#1


keeps saying
Oops, try again. There was a problem with your syntax.
please help


// 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> person2) {
         return person1.age;
        }    else {
        return person2.age;
        }
};


#2

Double bracket in IF condition in olderAge function ?


#3

Which one.Which Bracket


#4

if**(**(person1> person2) { <- one of it is unnessesary


#5

thanks mate I didnt notice it


#6

No problem :wink: keep coding :wink:

Greetings!


#7

But now i have a different problem keeps saying
It looks like your olderAge function fails when the first Person is older! It should return the age of the older person


#8

Look what you are comparating.
if (person1 > person2)

You are comparating whole object not their age :slight_smile: Try this one:
if (person1.age > person2.age)


#9

Thanks alot it worked


#10

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