How do I pass the ageDiiference function?


#1


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


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


// 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 = age(alice,billy);


#2

here:

var diff = age(alice,billy);

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


#3

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


#4

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


#5

yah ok. so do I remove this


var diff = age(alice,billy);
?


#6

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


#7

oh ok now I understand


#8

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