28/33 Help


#1

I get a syntax error. I may be very close or very far off... not sure at this point. Can someone help me figure this one out. In general for me the hardest thing about Js is syntax.Any advice?

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

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

// get the difference in age between alice and billy using our function
var diff = new ageDifference(alice, billy) {
return ageDifference();
}


#2

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

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

// get the difference in age between alice and billy using our function
ageDifference(alice, billy);


#3

I did
var diff = ageDifference(alice, billy)

TA DA!!!! THANK YOU!