Dagim H.#16
Conversation
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
reposman33
left a comment
There was a problem hiding this comment.
Looks good... just some minor remarks
| try { | ||
| fs.writeFileSync('books.json', JSON.stringify(books, null, 2), 'utf8'); | ||
| } catch (error) { | ||
| console.log(chalk.red('Error saving books.json')); |
There was a problem hiding this comment.
always nice to display the error message or just part of it like this: error. message or error.detail
| function addBook(book) { | ||
| // TODO: Implement this function | ||
| const books = loadBooks(); | ||
| const nextId = books.length ? Math.max(...books.map((b) => b.id)) + 1 : 1; |
There was a problem hiding this comment.
nice... we can' t assume an array of [1,2,3,4,5]. Maybe is is not sequentially ordered like [4,2,3,5,1].
| function getBooksByGenre(genre) { | ||
| // TODO: Implement this function using filter() | ||
| return loadBooks().filter( | ||
| (book) => book.genre.toLowerCase() === genre.toLowerCase(), |
There was a problem hiding this comment.
good catch to convert to lowercase first but genre can be converted outside the loop because it doesn't change (as opposed to book.genre). Devs like to see this attention to detail
| // Use green for read books, yellow for unread | ||
| // Use cyan for titles | ||
| const books = loadBooks(); | ||
| console.log(chalk.bold('\n📚 MY READING LIST 📚\n')); |
There was a problem hiding this comment.
you have this console.log('📚 MY READING LIST 📚\n'); already on line 18 of app.js :)
No description provided.