Compare commits
3 Commits
fe94193f97
...
3faa9634ab
Author | SHA1 | Date |
---|---|---|
NetMan | 3faa9634ab | |
NetMan | 2d76b4cb78 | |
NetMan | d8d93e38e0 |
|
@ -1,5 +1,8 @@
|
||||||
const getTheTitles = function() {
|
const getTheTitles = function(array) {
|
||||||
|
const titles = array.map((obj) => {
|
||||||
|
return obj.title;
|
||||||
|
})
|
||||||
|
return titles;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Do not edit below this line
|
// Do not edit below this line
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
const findTheOldest = function() {
|
const findTheOldest = function(array) {
|
||||||
|
const oldest = array.sort((a, b) => {
|
||||||
|
let yearNow = (new Date()).getFullYear();
|
||||||
|
let ageA = ((a.yearOfDeath) ? a.yearOfDeath : yearNow) - a.yearOfBirth;
|
||||||
|
let ageB = ((b.yearOfDeath) ? b.yearOfDeath : yearNow) - b.yearOfBirth;
|
||||||
|
return (ageA > ageB) ? -1 : 1;
|
||||||
|
})[0];
|
||||||
|
return oldest;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Do not edit below this line
|
// Do not edit below this line
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe('findTheOldest', () => {
|
||||||
]
|
]
|
||||||
expect(findTheOldest(people).name).toBe('Ray');
|
expect(findTheOldest(people).name).toBe('Ray');
|
||||||
});
|
});
|
||||||
test.skip('finds the person with the greatest age if someone is still living', () => {
|
test('finds the person with the greatest age if someone is still living', () => {
|
||||||
const people = [
|
const people = [
|
||||||
{
|
{
|
||||||
name: "Carly",
|
name: "Carly",
|
||||||
|
@ -40,7 +40,7 @@ describe('findTheOldest', () => {
|
||||||
]
|
]
|
||||||
expect(findTheOldest(people).name).toBe('Ray');
|
expect(findTheOldest(people).name).toBe('Ray');
|
||||||
});
|
});
|
||||||
test.skip('finds the person with the greatest age if the OLDEST is still living', () => {
|
test('finds the person with the greatest age if the OLDEST is still living', () => {
|
||||||
const people = [
|
const people = [
|
||||||
{
|
{
|
||||||
name: "Carly",
|
name: "Carly",
|
||||||
|
|
Loading…
Reference in New Issue