mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
add titles exercise
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# Get the Titles!
|
||||
|
||||
You are given an array of objects that represent books with an author and a title that looks like this:
|
||||
|
||||
```javascript
|
||||
const books = [
|
||||
{
|
||||
title: 'Book',
|
||||
author: 'Name'
|
||||
},
|
||||
{
|
||||
title: 'Book2',
|
||||
author: 'Name2'
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
your job is to write a function that takes the array and returns an array of titles:
|
||||
|
||||
```javascript
|
||||
getTheTitles(books) // ['Book','Book2']
|
||||
```
|
||||
|
||||
## Hints
|
||||
|
||||
- You should use a built-in javascript method to do most of the work for you!
|
||||
@@ -0,0 +1,5 @@
|
||||
const getTheTitles = function() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = getTheTitles;
|
||||
@@ -0,0 +1,19 @@
|
||||
let getTheTitles = require('./getTheTitles')
|
||||
|
||||
describe('getTheTitles', function() {
|
||||
const books = [
|
||||
{
|
||||
title: 'Book',
|
||||
author: 'Name'
|
||||
},
|
||||
{
|
||||
title: 'Book2',
|
||||
author: 'Name2'
|
||||
}
|
||||
]
|
||||
|
||||
it('gets titles', function() {
|
||||
expect(getTheTitles(books)).toEqual(['Book','Book2']);
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user