Passing the objects to functions


#1

28 how do i call the function with 2 objects in it ? :3


"Oops, try again. Make sure that diff is equal to the result of calling ageDifference with alice and billy as the arguments!"


// 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 = ageDifference("Alice", "Billy");

help


#2

here:

var diff = ageDifference("Alice", "Billy");

alice and bill should be the object instances, not strings


#3

oh i see hahahahhaha
its funny how I make mistake on this simple error
I declare ALICE AND BILLY in this format "alice" and "billy"

and I tried so many times in this syntax
var diff = ageDifference (Alice, Billy);
hahahahha then i came up with
var diff = ageDifference("Alice", "Billy");

and now i realized that my mistake is the for of "A" to a and "B" to b hahahahahha
thanks stetin you made me realized that clumsy mistake


#4