London | 25-ITP-Sep | Adnaan Abo | Sprint 2 | book library project#344
London | 25-ITP-Sep | Adnaan Abo | Sprint 2 | book library project#344AdnaanA wants to merge 5 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. |
|
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. |
1 similar comment
|
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. |
1 similar comment
|
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. |
| <button | ||
| type="button" | ||
| class="btn btn-primary mt-3" | ||
| onclick="addBook()" |
There was a problem hiding this comment.
It's a better practice to "attach event listener via JS" than "mixing JS code in HTML".
| bookTitle.value.trim(), | ||
| author.value.trim(), | ||
| pages.value.trim(), |
There was a problem hiding this comment.
-
It is a good practice to save sanitized or pre-processed values in some variables first
- to avoid calling
.trim()repeatedly, and - to reduce the chance of accidently using the raw value.
- to avoid calling
-
The book's
pageproperty can still be assigned some invalid page count.
There was a problem hiding this comment.
we can clean the values once and store them in variables: instead of the above code we could do
const titleValue = bookTitle.value.trim();
const authorValue = author.value.trim();
const pagesValue = pages.value.trim();
and we can over come the page being assigned invalid count we can do this
const pagesNumber = Number(pagesValue);
if (!Number.isInteger(pagesNumber) || pagesNumber <= 0) {
alert("Please enter a valid positive page count!");
return;
}
| // remove all rows except the header | ||
| while (table.rows.length > 1) { | ||
| table.deleteRow(1); | ||
| } |
There was a problem hiding this comment.
To clear the table before repopulating it, instead of deleting the table rows one by one, can you think of a more efficient way to remove all rows (except the <th>...</th>) in the table?
There was a problem hiding this comment.
we can use tbody.innerHTML = ''; to clear all rows efficiently.
however we have to use const row = tbody.insertRow(); to insert rows into tbody.
| delBut.id = i + 5; | ||
| deleteCell.appendChild(delBut); | ||
| // delete button | ||
| const deleteCell = row.insertCell(4); |
There was a problem hiding this comment.
Can you think of the pros and cons of these two approaches for creating cells within a row?
- Keeping all the cell creation code in one location, like the original code does.
- Scattering the cell creation code across different locations, like what you did.
There was a problem hiding this comment.
Keeping all cells created in one block is the best practice.
It is clearer, safer, easier to maintain, and less likely to produce bugs.
while
Scattered cell creation should only be used when absolutely necessary for conditional or dynamic table structures.
|
Changes look good. Well done.` |
Self checklist
Changelist
also ran html validation using w3c and fixed all the recommendations.