28 Passing Objects into Functions


I'm stuck with this error message plz help!

SyntaxError: Unexpected end of input

// 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 = function ageDifference(alice, billy)


var diff = function ageDifference(alice, billy) // remove function word

you are calling the function.so you just need to write the name of the function.


Thank you for answering my question in an incredibly short time


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