-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (28 loc) · 1.27 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* TODO:
* Buatlah variabel greatAuthors yang merupakan array
* berdasarkan hasil filter() dan map() dari books:
* - Gunakan fungsi filter untuk mengembalikan nilai item books
* yang hanya memiliki nilai sales lebih dari 1000000.
* - Gunakan fungsi map pada books yang sudah ter-filter,
* untuk mengembalikan nilai string dengan format:
* - `${author} adalah penulis buku ${title} yang sangat hebat!`
*
* Catatan: Jangan ubah nilai atau struktur dari books
*/
const books = [
{ title: 'The Da Vinci Code', author: 'Dan Brown', sales: 5094805 },
{ title: 'The Ghost', author: 'Robert Harris', sales: 807311 },
{ title: 'White Teeth', author: 'Zadie Smith', sales: 815586 },
{ title: 'Fifty Shades of Grey', author: 'E. L. James', sales: 3758936 },
{ title: 'Jamie\'s Italy', author: 'Jamie Oliver', sales: 906968 },
{ title: 'I Can Make You Thin', author: 'Paul McKenna', sales: 905086 },
{ title: 'Harry Potter and the Deathly Hallows', author: 'J.K Rowling', sales: 4475152 },
];
// TODO
let greatAuthors = books.filter((book) => book.sales > 1000000);
greatAuthors = greatAuthors.map((book) => `${book.author} adalah penulis buku ${book.title} yang sangat hebat!`);
/**
* Hiraukan kode di bawah ini
*/
module.exports = { books, greatAuthors };