Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions reading-list-manager/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"semi": true,
"printWidth": 80
}
39 changes: 37 additions & 2 deletions reading-list-manager/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
// This is the entrypoint for your application.
// node app.js
const chalk = require('chalk');
const {
printAllBooks,
printSummary,
getUnreadBooks,
getBooksByGenre,
addBook,
markAsRead,
} = require('./readingList');
const command = process.argv[2];


// TODO: Implement the main application logic here
// 1. Load books on startup
Expand All @@ -8,6 +19,30 @@
// 4. Add example of filtering by genre or read/unread status
// 5. Add example of marking a book as read

console.log('📚 MY READING LIST 📚\n');
printAllBooks();
printSummary();

// Example: filter unread
const unread = getUnreadBooks();
console.log('\nUnread Books:');
unread.forEach((book) => console.log(`${book.id}. ${book.title}`));

// Example: filter by genre
const fiction = getBooksByGenre('Fiction');
console.log('\nFiction Books:');
fiction.forEach((book) => console.log(`${book.id}. ${book.title}`));

// Example: add new book
if (command === 'add') {
const title = process.argv[3];
const author = process.argv[4];
const genre = process.argv[5];
addBook({ title: 'Brave New World', author: 'Aldous Huxley', genre: 'Fiction' });
}

// Example: mark a book as read
markAsRead(2);

// Your implementation here
console.log('\nAfter updates:');
printAllBooks();
printSummary();
38 changes: 37 additions & 1 deletion reading-list-manager/books.json
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
[]
[
{
"id": 1,
"title": "1984",
"author": "George Orwell",
"genre": "Fiction",
"read": false
},
{
"id": 2,
"title": "Dune",
"author": "Frank Herbert",
"genre": "Sci-Fi",
"read": true
},
{
"id": 3,
"title": "The Hobbit",
"author": "J.R.R. Tolkien",
"genre": "Fantasy",
"read": true
},
{
"id": 4,
"title": "Sapiens",
"author": "Yuval Noah Harari",
"genre": "Non-fiction",
"read": false
},
{
"id": 5,
"title": "Clean Code",
"author": "Robert C. Martin",
"genre": "Programming",
"read": true
}
]
105 changes: 105 additions & 0 deletions reading-list-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions reading-list-manager/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "reading-list-manager",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"dependencies": {
"chalk": "^4.1.2"
},
"devDependencies": {
"prettier": "^3.8.1"
}
}
Loading