-
-
Notifications
You must be signed in to change notification settings - Fork 158
Glasgow | 25-ITP-SEP | Fares Bakhet | Sprint 2 | Book-library #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Glasgow | 25-ITP-SEP | Fares Bakhet | Sprint 2 | Book-library #345
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md
Doing so can help me speed up the review process. Thanks.
debugging/book-library/index.html
Outdated
| <script src="script.js"></script> | ||
| <script type="module"> | ||
| class Book { | ||
| constructor(title, author, pages, read) { | ||
| this.title = title; | ||
| this.author = author; | ||
| this.pages = pages; | ||
| this.read = read; | ||
| } | ||
| } | ||
|
|
||
| const library = [ | ||
| new Book("Robinson Crusoe", "Daniel Defoe", 252, true), | ||
| new Book("The Old Man and the Sea", "Ernest Hemingway", 127, true) | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why keep the JS code in this HTML file? Should I be reviewing the code in the HTML file or those in script.js?
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great. Just one question.
debugging/book-library/script.js
Outdated
| <td>${book.title}</td> | ||
| <td>${book.author}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you suggest an approach to combat special characters such as '<' and '&' that may exist in a book title? If these characters are not handled properly, they may ruin the display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjyuan, Okay, will use "textContent" instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also write a function to escape the special characters in the string. (Just ask AI. The function is just a few lines of code).
Then you would be able to express something like:
`...
<td>${escape(book.title)}</td>
<td>${escape(book.author)}</td>
...
`
This way, you can keep using your approach to construct the elements.
Learners, PR Template
Self checklist
Changelist
Complete the book library adjustments.
Questions
No questions.