Files
odin-javascript-exercises/12_findTheOldest/README.md
T
Nikita Revenco 1695abe9d4 Exercise 12: Provide alternative solution (#459)
* feat(12): improve solution by making it more cleaner

* refactor(12): rename `array` to `people`

* feat(12): improve explanation of `??=`

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>

* feat(12): include both solutions

* feat(12): hint to use various array methods

* refactor(12): add semicolon

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>

* feat(12): use block comments instead of line for readability

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>

* refactor(12): remove unnecessary comment

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>

---------

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
2024-05-03 16:30:56 +01:00

730 B

Exercise 12 - Find the Oldest

Given an array of objects representing people with a birth and death year, return the oldest person.

Now that you've reached the final exercise, you should be fairly comfortable getting the information you need from test case(s). Take a look at how the array of objects is constructed in this exercise's test cases to help you write your function.

Hints

  • You should return the whole person object, but the tests mostly just check to make sure the name is correct.
  • There are many ways of doing this using built-in array methods like reduce, or even chaining multiple!
  • One of the tests checks for people with no death-date.. use JavaScript's Date function to get their age as of today.