Skip to main content
Table of contents

Back to challenges

Challenge 3 - Age Difference

Write a function ageDifference that returns the difference in age between the oldest and youngest member of a family.

It should take two parameters: youngest, and oldest. These will always be objects.

Use the following two as your test cases:

var youngest = {
  name: 'Maya',
  age: 13
};
var oldest = {
  name: 'Joy',
  age: 83
};

Successfully calling the function will look like this:

ageDifference(youngest, oldest); // ---> returns 70

Solution

Next challenge

This page was last reviewed on 3 February 2022. It needs to be reviewed again on 3 February 2023 .
This page was set to be reviewed before 3 February 2023. This might mean the content is out of date.