Skip to content

Commit ea5aeaf

Browse files
authored
Merge pull request #2 from fielded/callbacks
callback functions
2 parents 064de71 + c4f7085 commit ea5aeaf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

javascript/books.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ var books = [
6161
},
6262
]
6363

64-
export default book
64+
export default books

javascript/callbacks.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import books from './books'
2+
3+
const filterBooksWithTitleStartingWithA = (sortedBooks, callback) => {
4+
let filteredBooks
5+
/* filter logic here */
6+
return callback(filteredBooks)
7+
}
8+
9+
const sortBooksAlphabetically = (books, callback) => {
10+
let sortedBooks
11+
/* sorting logic books */
12+
return callback(sortedBooks)
13+
}
14+
15+
const getBooksAsync = (callback) => {
16+
setTimeout((books) => {
17+
callback(books, filterBooksWithTitleStartingWithA)
18+
}, 2000)
19+
}
20+
21+
getBooksAsync(sortBooksAlphabetically)

0 commit comments

Comments
 (0)