Glasgow | 25-ITP-Sep |Hanna Mykytiuk| Sprint 2 | Book library#348
Glasgow | 25-ITP-Sep |Hanna Mykytiuk| Sprint 2 | Book library#348HannaOdud wants to merge 7 commits intoCodeYourFuture:mainfrom
Conversation
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
4 similar comments
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
cjyuan
left a comment
There was a problem hiding this comment.
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.
|
Thank you @cjyuan for reminding me about feedback file, it was quite useful. I have applied changes for there. |
cjyuan
left a comment
There was a problem hiding this comment.
The app is not working properly yet. Can you fix the bugs?
Suggestion: Ask an AI to review your code and update your code accordingly but only if you also agree with what the AI suggests.
| pages.value == "" | ||
| titleDom.value == "" || | ||
| authorDom.value == "" || | ||
| pagesDom.value == 0 |
There was a problem hiding this comment.
What is the type of the pagesDom.value? Why compare it to 0?
| } else { | ||
| let book = new Book(title.value, title.value, pages.value, check.checked); | ||
| library.push(book); | ||
| let book = new Book(titleDom.value.trim(), authorDom.value.trim(), pagesDom.value, checkDom.checked); |
There was a problem hiding this comment.
The values you used on line 40 are not the values you checked on lines 33-35. A book may end up having an empty string as its title or a negative number as its page count.
A better practice is
Step 1: Sanitised and preprocessed the raw input values and stored the resulting value in some variables.
Step 2; Check the values in the variables
Step 3: If the values are ok, use the values stored in the variables.
cjyuan
left a comment
There was a problem hiding this comment.
You cleared all rows in <tbody> but your app is still adding rows to <table> (instead of adding rows to <tbody>. If you add new books to the app, you will see the problem with the current implementation.
| const title = sanitize(titleDom.value.trim()); | ||
| const author = sanitize(authorDom.value.trim()); | ||
| const pages = sanitize(pagesDom.value.trim()); |
There was a problem hiding this comment.
Why convert the "special characters" in the input?
There was a problem hiding this comment.
Now I used other sanitization. From first example of:
| } else { | ||
| let book = new Book(title.value, title.value, pages.value, check.checked); | ||
| library.push(book); | ||
| let book = new Book(title, author, pages, checkDom.checked); |
There was a problem hiding this comment.
pages is still a string. A value like "3.14" or "3e1" could make past the check on line 38-39.
There was a problem hiding this comment.
Now value converted to integer ( if possible).
| let readStatus = ""; | ||
| if (myLibrary[i].check == false) { | ||
| readStatus = "Yes"; | ||
| } else { | ||
| readStatus = "No"; | ||
| } else { | ||
| readStatus = "Yes"; | ||
| } | ||
| changeBut.innerText = readStatus; | ||
| changeBut.textContent = readStatus; |
There was a problem hiding this comment.
This could be a good opportunity to practice using the ? : conditional operator. Can you rewrite the code on lines 92–98 as a single statement?
There was a problem hiding this comment.
Thanks for advise. Now it refactored.
| } | ||
|
|
||
| function isValueInteger(value) { | ||
| return Number.isInteger(value); |
There was a problem hiding this comment.
Could probably just use Number.isInteger() in the if condition directly.
Learners, PR Template
Self checklist
Changelist
Bugfixing of book library app.
Questions
No questions