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
Follow the Assignment submission guide to learn how to submit the assignment
The HackYourFuture curriculum is licensed underย CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

Built with โค๏ธ by the HackYourFuture community ยท Thank you, contributors
Found a mistake or have a suggestion? Let us know in the feedback form.