---
id: 69e2383af7832c8032603b90
title: "Challenge 274: Oldest Person"
challengeType: 28
dashedName: challenge-274
---

# --description--

Given an array of objects, each with a `"name"` and `"age"` property, return an array containing the name of the oldest person.

If multiple people share the oldest age, return all of their names in the order they appear in the input.

# --hints--

`getOldest([{ name: "Brenda", age: 40 }])` should return `["Brenda"]`.

```js
assert.deepEqual(getOldest([{ name: "Brenda", age: 40 }]), ["Brenda"]);
```

`getOldest([{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }])` should return `["Alice"]`.

```js
assert.deepEqual(getOldest([{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]), ["Alice"]);
```

`getOldest([{ name: "Allison", age: 25 }, { name: "Bill", age: 30 }, { name: "Carol", age: 30 }])` should return `["Bill", "Carol"]`.

```js
assert.deepEqual(getOldest([{ name: "Allison", age: 25 }, { name: "Bill", age: 30 }, { name: "Carol", age: 30 }]), ["Bill", "Carol"]);
```

`getOldest([{ name: "George", age: 50 }, { name: "Shirley", age: 42 }, { name: "Beth", age: 48 }, { name: "Holly", age: 50 }, { name: "Kevin", age: 44 }, { name: "Frank", age: 47 }, { name: "Zach", age: 50 }, { name: "Jennifer", age: 43 }])` should return `["George", "Holly", "Zach"]`.

```js
assert.deepEqual(getOldest([{ name: "George", age: 50 }, { name: "Shirley", age: 42 }, { name: "Beth", age: 48 }, { name: "Holly", age: 50 }, { name: "Kevin", age: 44 }, { name: "Frank", age: 47 }, { name: "Zach", age: 50 }, { name: "Jennifer", age: 43 }]), ["George", "Holly", "Zach"]);
```

# --seed--

## --seed-contents--

```js
function getOldest(people) {

  return people;
}
```

# --solutions--

```js
function getOldest(people) {
  const maxAge = Math.max(...people.map(p => p.age));
  return people.filter(p => p.age === maxAge).map(p => p.name);
}
```
