mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-19 22:53:27 +09:00
add findOldest Solutions
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
let findTheOldest = require('./findTheOldest')
|
||||
|
||||
describe('findTheOldest', function() {
|
||||
it('finds the oldest person!', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
yearOfBirth: 1942,
|
||||
yearOfDeath: 1970,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
});
|
||||
it('finds the oldest person if someone is still living', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
yearOfBirth: 2018,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
});
|
||||
it('finds the oldest person if the OLDEST is still living', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
yearOfBirth: 1066,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Carly');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user