Style - How to write meaningful comments
Build a command-line reading list that saves to files using error handling and array methods.
package.json[email protected].gitignore for node_modules/.prettierrcStore books in books.json:
[
{
id: 1,
title: "1984",
author: "George Orwell",
genre: "Fiction",
read: false
}
// ... at least 5 books
]
File operations with error handling:
loadBooks() - Read from file, create empty array if missingsaveBooks(books) - Write to file with try-catchaddBook(book) - Add and saveArray method functions:
getUnreadBooks() - Use filter()getBooksByGenre(genre) - Use filter()markAsRead(id) - Use map() to updategetTotalBooks() - Use lengthhasUnreadBooks() - Use some()Display functions:
printAllBooks() - Loop through and display with chalkprintSummary() - Show statisticsMust handle:
books.json (create empty array)Create working program with:
📚 MY READING LIST 📚
All Books:
1. 1984 by George Orwell (Fiction) ✓ Read
2. Dune by Frank Herbert (Sci-Fi) ⚠ Unread
3. The Hobbit by J.R.R. Tolkien (Fantasy) ✓ Read
📊 SUMMARY 📊
Total Books: 3
Read: 2
Unread: 1
The assignment repository can be found in https://github.com/HackYourAssignment/ with the name cXX-core-week-## (Replace XX with your cohort number and ## with the week number)
Follow the Assignment submission guide to learn how to submit the assignment

Found a mistake or have a suggestion? Let us know in the feedback form.