Conversation
This comment has been minimized.
This comment has been minimized.
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
sycons
left a comment
There was a problem hiding this comment.
Well done! ⭐
You did the assignment well and showed understanding of the concepts.
- Setup & Configuration ✅
- Data Structure ✅
- Required Functions ✅
- Error Handling ✅
- Display (Chalk) ✅
| import chalk from 'chalk' | ||
|
|
||
| const dataDir = '.' | ||
| const BOOKS = path.join(dataDir, 'books.json') |
There was a problem hiding this comment.
A more helpful name would be booksPath. Currently with this name it looks like this variable holds the array of books. This can be a little misleading.
| const data = fs.readFileSync(BOOKS, 'utf-8') | ||
| return JSON.parse(data) | ||
| } catch (error) { | ||
| if (error.code === 'ENOENT') { |
There was a problem hiding this comment.
Good job handling errors based on the type of error ⭐
| console.log('Invalid JSON in books.json. Starting with empty list.') | ||
| return [] | ||
| } | ||
| throw error |
There was a problem hiding this comment.
For unhandled errors, it is better to log it and then return an empty error, than to just throw the error.
| console.log('📚 MY READING LIST 📚\n'); | ||
| // 4. 4. Add example of filtering by genre or read/unread status | ||
| console.log(chalk.bold('\n📖 Unread Books:')); | ||
| const unread = getUnreadBooks(); |
There was a problem hiding this comment.
Well done using the other functions and seeing them in action ⭐
No description provided.