write a function that takes the array and returns an array of titles:

This commit is contained in:
Akutsang 2023-02-03 23:46:43 +01:00
parent 8339f3e8d2
commit 97980c9e3f
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,19 @@
const getTheTitles = function() {
const books = [
{
title: 'Book',
author: 'Name'
},
{
title: 'Book2',
author: 'Name2'
}
]
return books.map(function(book){
return book.title;
})
};
// Do not edit below this line
module.exports = getTheTitles;

View File

@ -16,3 +16,4 @@ describe('getTheTitles', () => {
expect(getTheTitles(books)).toEqual(['Book','Book2']);
});
});