I don't understand how?


#1


Sorry this seems easy but I don't know how to call the person things or the ageDiffrence



https://www.codecademy.com/courses/spencer-sandbox/4/3?curriculum_id=506324b3a7dffd00020bf661#


// 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 =


What's wong with my code?


#2

Call your ageDifference() function and pass them variables(names) alice and billy.

hint**
you created function ageDifference() to take two parameters(people names ) and return you age difference!


#3

how do I do that is what I'm wondering. if you can at least link something that would be helpful


#4

hint**
if x and y are two objects created from Person Constructor then I will pass them to ageDifference() as ageDifference(x,y)


#5

ohhhhh ok

thanks


#6

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