-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew-5.js
More file actions
28 lines (26 loc) · 919 Bytes
/
Copy pathnew-5.js
File metadata and controls
28 lines (26 loc) · 919 Bytes
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
const goodreadsInfo = {
currentlyReading: [
{ title: "The Hobbit", author: "J.R.R. Tolkien" },
{ title: "The Two Towers", author: "J.R.R. Tolkien" }
],
wantToRead: [
{ title: "The Art of Language Invention", author: "David Peterson" },
{ title: "Looking for Alaska", author: "John Green" }
]
};
const addNewBooks = (books, additionalBookObjects = []) => {
return [...books, ...additionalBookObjects];
}
goodreadsInfo.currentlyReading = addNewBooks(goodreadsInfo.currentlyReading, [{ title: "The MOM Test", author: "Rob Fitzpatrick" }]);
const showGoodreadsInfo = (info) => {
console.log("Currently Reading:");
for (let x of info.currentlyReading) {
console.log(`${x.title} by ${x.author}`);
}
console.log();
console.log("Want to Read:");
for (let x of info.wantToRead) {
console.log(`${x.title} by ${x.author}`);
}
}
showGoodreadsInfo(goodreadsInfo);