mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-16 13:13:19 +09:00
@@ -7,4 +7,3 @@ given an array of objects representing people with a birth and death year, retur
|
||||
- this can be done with a couple of chained array methods, or by using `reduce`.
|
||||
- One of the tests checks for people with no death-date.. use JavaScript's Date function to get their age as of today.
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const findTheOldest = function() {
|
||||
let findTheOldest = function () {};
|
||||
|
||||
}
|
||||
|
||||
module.exports = findTheOldest
|
||||
module.exports = findTheOldest;
|
||||
|
||||
@@ -1,64 +1,62 @@
|
||||
const findTheOldest = require('./findTheOldest')
|
||||
const findTheOldest = require("./findTheOldest");
|
||||
|
||||
describe('findTheOldest', () => {
|
||||
test('finds the oldest person!', () => {
|
||||
describe("findTheOldest", () => {
|
||||
test("finds the oldest person!", () => {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 1942,
|
||||
yearOfDeath: 1970,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
];
|
||||
expect(findTheOldest(people).name).toBe("Ray");
|
||||
});
|
||||
test.skip('finds the oldest person if someone is still living', () => {
|
||||
xit("finds the oldest person if someone is still living", function () {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 2018,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
];
|
||||
expect(findTheOldest(people).name).toBe("Ray");
|
||||
});
|
||||
test.skip('finds the oldest person if the OLDEST is still living', () => {
|
||||
xit("finds the oldest person if the OLDEST is still living", function () {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 1066,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Carly');
|
||||
];
|
||||
expect(findTheOldest(people).name).toBe("Carly");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user