29 syntax eror after argument list


#1

I sure can not see this error// 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;}

else
   { return person2;}

};

// 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;(aice,billy));
};


#2

updated code, still have the same prob.. thanksfunction 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));


#3

I found it, semi-colon in call line after olderAge and then added a semi colon after the curly bracket to close out the last function. The argument statement the editor was talking about was in the call line


#4

THIS IS MY CODE AND IT KEEPS SAYING THEIR IS A SYNTAX ERROR

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);
var diff = ageDifference(Alice, Billy);
console.log(diff);


#5

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


#6

semi colon after return person1.age;

also after return person2.age ;

You may not need to add the diff on the call. Check my 2nd post


#7

thanks, got it now, I had a semi colon after the return person2.age and it worked.