28. Shows right answer but still an error


The answer is 5, and it gives it out. But it says that it is wrong.

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!

// 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 difference between Allice and Billy is", ageDifference(alice, billy));

Thanks for any kind of answers. :slight_smile:



There is only one parameter that console.log function will accept. If you separate them with comma, they will be considered as other parameter. To concatenate strings and object together, we use + sign. Like if we want to concatenate "Java" and "Script"

console.log("Java" + "Script");

This will output JavaScript. Note that spaces count as character for separating each word. You can do the same as for object, numbers, or variable, just not putting quotes between them like strings do.


Thank you. :slight_smile: I forgot.