Photo by Ekaterina Shakharova on Unsplash

# Find the Difference in Age between Oldest and Youngest Family Members - Codewars 8KYU

"At the annual family gathering, the family likes to find the oldest living family member’s age and the youngest family member’s age and calculate the difference between them.

You will be given an array of all the family members' ages, in any order. The ages will be given in whole numbers, so a baby of 5 months, will have an ascribed ‘age’ of 0. Return a new array (a tuple in Python) with [youngest age, oldest age, difference between the youngest and oldest age]."

We're given a function with the parameter with the name of ages:

Since we're trying to figure out what the age gap is between the oldest living relative, and the youngest.
I figured we could tackle the problem by using two methods, ** Math.max()** and

**.**

*Math.min()***returns the largest number in an array and**

*Math.max()***returns the the smallest number in an array.**

*Math.min()*By using those, we can assign a variable ** oldest** to

**, and a variable**

*Math.max()***to**

*youngest***. With both taking in a**

*Math.min()***.**

*spread operator of (...ages)*A spread operator, according to the MDN,

"Spread syntax (...) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. "

After successfully getting access to the oldest and youngest ages in the family. Now we can assign a variable ** difference**, that will subtract the variables

**from the**

*oldest***.**

*youngest*Then, we can return an array containing the difference between the oldest and youngest ages in the array.