8000 add titles exercise · kennyslater/javascript-exercises@341661a · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 341661a

Browse files
committed
add titles exercise
1 parent a69e6ea commit 341661a

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

getTheTitles/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Get the Titles!
2+
3+
You are given an array of objects that represent books with an author and a title that looks like this:
4+
5+
```javascript
6+
const books = [
7+
{
8+
title: 'Book',
9+
author: 'Name'
10+
},
11+
{
12+
title: 'Book2',
13+
author: 'Name2'
14+
}
15+
]
16+
```
17+
18+
your job is to write a function that takes the array and returns an array of titles:
19+
20+
```javascript
21+
getTheTitles(books) // ['Book','Book2']
22+
```
23+
24+
## Hints
25+
26+
- You should use a built-in javascript method to do most of the work for you!

getTheTitles/getTheTitles.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const getTheTitles = function() {
2+
3+
}
4+
5+
module.exports = getTheTitles;

getTheTitles/getTheTitles.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let getTheTitles = require('./getTheTitles')
2+
3+
describe('getTheTitles', function() {
4+
const books = [
5+
{
6+
title: 'Book',
7+
author: 'Name'
8+
},
9+
{
10+
title: 'Book2',
11+
author: 'Name2'
12+
}
13+
]
14+
15+
it('gets titles', function() {
16+
expect(getTheTitles(books)).toEqual(['Book','Book2']);
17+
});
18+
19+
});

0 commit comments

Comments
 (0)
0