# Need help,I've done my best

#1

// 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) {
switch(olderAge){
case(person1.age==person2.age):
return"same age";
break;
};
case(person1.age<=person2.age):
return person2.age;
break;
};
case(person1.age>=person2.age):
return person1.age;
break;
};
};
// 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

Hi,

you didnt can compare like you did in a switch case.
Use here If /else if / else

#3

// 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 if(person1.age return person2.age;
};
else{
return "no one";
};
};

var alice = new Person("Alice", 30);
var billy = new Person("Billy", 25);

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

SyntaxError: Unexpected token else

#4

``````}; // remove semicolon
else if(person1.age    // nothing to compare??  //no closing bracket
// no opening curly bracket
return person2.age;

}; // remove semicolon
else{
return "no one";``````