I don't understand how?


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


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


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

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


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


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


ohhhhh ok



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