-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathreading-lists.js
50 lines (42 loc) · 1.11 KB
/
reading-lists.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Reading Lists 📖
// Codédex
const goodreadsInfo = {
currentlyReading: [
{
title: "The Hobbit",
author: "J.R.R. Tolkien",
},
],
wantToRead: [
{
title: "The Art of Language Invention",
author: "David Peterson",
},
],
};
const addNewBook = (books, ...additionalBookObjects) => {
return [...books, ...additionalBookObjects];
};
goodreadsInfo.currentlyReading = addNewBook(
goodreadsInfo.currentlyReading,
{ title: "The Two Towers", author: "J.R.R. Tolkien" },
{ title: "The MOM Test", author: "Rob Fitzpatrick" }
);
goodreadsInfo.wantToRead = addNewBook(goodreadsInfo.wantToRead, {
title: "Looking for Alaska",
author: "John Green",
});
const showGoodreadsInfo = (info) => {
const currentlyReading = info.currentlyReading;
const wantToRead = info.wantToRead;
console.log("Currently Reading:");
for (let book of currentlyReading) {
console.log(`${book.title} by ${book.author}`);
}
console.log();
console.log("Want to Read:");
for (let book of wantToRead) {
console.log(`${book.title} by ${book.author}`);
}
};
showGoodreadsInfo(goodreadsInfo);