Help me!


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

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 = function (alice, billy) {
return alice.age - billy.age;
}

Instructions
We have created two example people, alice and billy. Complete line 17 by calling ageDifference and saving the result in our global diff variable.


#2

What error are you getting?


#3

Oops, try again. Make sure to call the ageDifference function.


#4

Jk thats not it. What section is this? XD


#5

the same Oops, try again. Make sure to call the ageDifference function.


#6

which is right?
write and send me. please!


#7

What section is this in?


#8

Introduction to Objects I

Passing Objects into Functions


#9

Ooo...Replace this:

var diff = function (alice, billy) {
return alice.age - billy.age;
}

with this:

var diff = ageDifference(alice,billy);

You were creating a new function. To call it, all you have to do it the above.


#10

it helped. thank you