Skip to content

Conversation

@TarasMykytiuk
Copy link

@TarasMykytiuk TarasMykytiuk commented Aug 17, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.
In this branch was performed bugfixing of Book library app.

Questions

Ask any questions you have for your reviewer.

@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

3 similar comments
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

@TarasMykytiuk TarasMykytiuk added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 17, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

1 similar comment
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (Module-Data-Flows) doesn't match expected format (example: 'Sprint 2', without quotes)

@TarasMykytiuk TarasMykytiuk changed the title GLASGOW | May-2025 | Taras Mykytiuk | Module-Data-Flows | Book library GLASGOW | May-2025 | Taras Mykytiuk | Module-Data-Flows | Sprint 2 | Book library Aug 17, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

@TarasMykytiuk TarasMykytiuk changed the title GLASGOW | May-2025 | Taras Mykytiuk | Module-Data-Flows | Sprint 2 | Book library GLASGOW | May-2025 | Taras Mykytiuk | Sprint 2 | Book library Aug 17, 2025
Copy link
Contributor

@cjyuan cjyuan left a 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.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 17, 2025
@TarasMykytiuk TarasMykytiuk added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 18, 2025
@TarasMykytiuk
Copy link
Author

Hi. Now I have taken feedback.md into account.

@TarasMykytiuk TarasMykytiuk removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Aug 18, 2025
function populateStorage() {
if (myLibrary.length == 0) {
let book1 = new Book("Robison Crusoe", "Daniel Defoe", "252", true);
let book1 = new Book("Robison Crusoe", "Daniel Defoe", Number("252"), true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the numeric literal 252?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did not think about it)

Comment on lines 29 to 31
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turns special characters to HTML entities. For example, > to >.
Have you checked what would happen if you include a character & in the title?


You can ask AI why this conversion is not needed when the input is assigned to the .textContent or .innerText properties.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Now I will consider this in future.

Comment on lines +39 to +41
function isHexadecimal(input) {
return /^0x[0-9a-fA-F]+$/.test(input);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you want to allow the user to enter a page count as a hexadecimal number?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont allow. When user try to input something like: "0x10" - this function return true and condition in line 50 trigger error alert window in line 53.

Comment on lines 47 to 65
bookTitleInput.value.trim() == "" ||
bookAuthorInput.value.trim() == "" ||
bookNumberOfPagesInput.value.trim() == ""
) {
alert("Please fill all fields!");
return false;
} else {
let book = new Book(title.value, author.value, pages.value, check.checked);
} else if (
isNaN(Number(bookNumberOfPagesInput.value.trim())) ||
!isValidInteger(Number(bookNumberOfPagesInput.value.trim())) ||
isHexadecimal(bookNumberOfPagesInput.value.trim()) ||
Number(bookNumberOfPagesInput.value.trim()) <= 0
) {
alert("Invalid number of pages format!");
return false;
} else {
const bookTitle = sanitizeInput(bookTitleInput.value.trim());
const bookAuthor = sanitizeInput(bookAuthorInput.value.trim());
const bookNumberOfPages = parseInt(sanitizeInput(bookNumberOfPagesInput.value.trim()), 10);
let book = new Book(bookTitle, bookAuthor, bookNumberOfPages, isBookReadCheckBox.checked);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For better performance (reduce number of function calls) and reducing the chance of using raw input accidently, we could stored the pre-processed/sanitized/normalized input in some variables first, and reference the variables in other part of the function.

  • Number.isInteger() would also return false when the input is not a number; we can omit isNaN() check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Now is more efficient.

Comment on lines 99 to 105
let readStatus = "";
if (myLibrary[i].check == false) {
readStatus = "No";
} else {
readStatus = "Yes";
}
changeBut.innerText = readStatus;
changeReadStatusButton.innerText = readStatus;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a good opportunity to practice using the ? : conditional operator. Can you rewrite the code on lines 99-105 as a single statement?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank. I just missed it.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 18, 2025
@TarasMykytiuk TarasMykytiuk added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 19, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

Comment on lines 46 to 55
<input
type="number"
type="text"
class="form-control"
id="pages"
name="pages"
required
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change type="number" to type="text" when Page count is supposed to be an integer? If anything, we should make the check stricter (to allow only digits in the input field).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)) Yes. Now fixed.

readStatus = "No";
}
changeBut.innerText = readStatus;
!myLibrary[i].check ? readStatus = "No" : readStatus = "Yes";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The common way to use ? : is
readStatus = !myLibrary[i].check ? "No" : "Yes";

!myLibrary[i].check ? "No" : "Yes" is an expression that evaluates to either "No" or "Yes".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review!

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants