-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary-manager.js
More file actions
89 lines (75 loc) · 2.48 KB
/
Copy pathlibrary-manager.js
File metadata and controls
89 lines (75 loc) · 2.48 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Practice Some Array methods
// map(),filter(), reduce() and join() method
const library = [
{
title: 'Your Next Five Moves: Master the Art of Business Strategy',
author: ' ',
about: 'A book on how to plan ahead',
pages: 320,
},
{
title: 'Atomic Habits',
author: 'James Clear',
about: 'A practical book about discarding bad habits and building good ones',
pages: 320,
},
{
title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few',
author: 'Patrick Bet-David',
about:
"A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world",
pages: 304,
},
{
title: 'The Embedded Entrepreneur',
author: 'Arvid Kahl',
about: 'A book focusing on how to build an audience-driven business',
pages: 308,
},
{
title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change',
author: 'Jon Gordon',
about: 'A book about effective ways to lead a coffee bean lifestyle',
pages: 256,
},
{
title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation',
author: 'Jeff DeGraff and Staney DeGraff',
about: 'A book on how to develop creativity and innovation skills',
pages: 168,
},
{
title: 'Rich Dad Poor Dad',
author: 'Robert Kiyosaki and Sharon Lechter',
about: 'A book about financial literacy, financial independence, and building wealth. ',
pages: 336,
},
{
title: 'Zero to Sold',
author: 'Arvid Kahl',
about: 'A book on how to bootstrap a business',
pages: 500,
},
];
console.log("Books in the Library:\n");
function getBookInformation(catalog) {
return catalog.map(book => `${book.title} by ${book.author}`).join("\n");
}
console.log(getBookInformation(library));
console.log("\nList of book summaries:\n");
function getBookSummaries(catalog) {
return catalog.map((book) => book.about).join("\n");
}
console.log(getBookSummaries(library));
console.log("\nList of books by Arvid Kahl:\n");
function getBooksByAuthor(catalog, author) {
return catalog.filter((book) => book.author === author);
}
console.log(getBooksByAuthor(library, "Arvid Kahl"));
console.log("\nList of books by James Clear:\n");
console.log(getBooksByAuthor(library, "James Clear"));
console.log("\nTotal number of pages for all library books:\n");
function getTotalPages(books){
return books.reduce((totalPage,curr)=> totalPage + curr.pages,0);
}
console.log(getTotalPages(library))