How do I pass the ageDiiference function?


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

// Our person constructor
function Person (name, age) { = 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 = age(alice,billy);



var diff = age(alice,billy);

you call a function named age, but your function is named agerDifference


I looked after I posted this topic and haven't changed the name


true, but your function is named ageDifference, this function you should call. But you call age, which is a non existing function


yah ok. so do I remove this

var diff = age(alice,billy);


no, you should rename age to the correct name so you call the correct function


oh ok now I understand


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