28. Passing Objects into Functions


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Oops, try again. It looks like the value of diff is not a number! Make sure you are setting it equal to ageDifference(alice,billy). Make sure not to put quotes around alice and billy!

```

Replace this line with your code.
// 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 = console.log("The age between Alice and Billy is " + ageDifference(alice,billy));

<do not remove the three backticks above>
Hi, there are some mistakes in my code that I am not able to notice by myself... Could someone point out for me please? Thanks so much.

#2
var diff = ageDifference(alice,billy);
console.log("The age between Alice and Billy is " + diff);

The SCT may not be expecting the output, so if there is a problem, comment the last line and keep only the first one.


#3

Thanks, problem solved.