Skip to content

London | 26-ITP-May | Rizqah Popoola | Sprint 2 |Book Library - #549

Open
risikatpopoola wants to merge 6 commits into
CodeYourFuture:mainfrom
risikatpopoola:feature/book-library
Open

London | 26-ITP-May | Rizqah Popoola | Sprint 2 |Book Library#549
risikatpopoola wants to merge 6 commits into
CodeYourFuture:mainfrom
risikatpopoola:feature/book-library

Conversation

@risikatpopoola

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

In this PR, i have fixed all the bugs in script.js and refactored the script to be more efficient. I have also validated the html code to ensure it's free of errors.

@github-actions

This comment has been minimized.

@risikatpopoola risikatpopoola added 🏕 Priority Mandatory This work is expected Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Flows The name of the module. labels Aug 13, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 13, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@risikatpopoola risikatpopoola changed the title London | 26-ITP-May | Rizqah Popoola | Sprint 3 |Book Library London | 26-ITP-May | Rizqah Popoola | Sprint 2 |Book Library Aug 13, 2026
@risikatpopoola risikatpopoola added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 13, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid start.

I think there are some improvements you could still make.

Comment thread debugging/book-library/index.html Outdated
Comment thread debugging/book-library/index.html Outdated
Comment thread debugging/book-library/script.js Outdated
@@ -1,46 +1,58 @@
let myLibrary = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we declare myLibrary in a way that prevents it from being accidentally reassigned?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have now declared this using const

Comment thread debugging/book-library/index.html Outdated
type="submit"
value="Submit"
class="btn btn-primary"
onclick="submit();"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you research the trade-off between

  • attaching event listener in HTML
  • attaching event listener usng .addEventListener() in JS?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It is easier to manage event listeners in js and it provides more control.

Comment thread debugging/book-library/script.js Outdated
Comment on lines +48 to +49
titleInput.value.trim(),
authorInput.value.trim(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A better and safer approach to deal with user input is to first preprocess/sanitise them, and then store the cleaned values in variables. Thereafter, refer only to the variables for cleaned values consistently throughout the rest of the code.

@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 13, 2026
@risikatpopoola risikatpopoola 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 16, 2026
Comment thread debugging/book-library/index.html Outdated
Comment thread debugging/book-library/index.html Outdated
Comment thread debugging/book-library/script.js Outdated
Comment on lines +80 to +82
const submitButton = document.getElementById("submit");

submitButton.addEventListener("click", submit);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why attach the event listener to the submit button here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I completely removed the event listener for the submit button and added it to the book form submission instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How many times do you expect the app to add the event listeners to the submit button?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It should only be once, i have now taken it out of setup

@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, 2026
@risikatpopoola risikatpopoola 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 17, 2026
@cjyuan

cjyuan commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Please note that if you have made any changes, you need to push them to GitHub.

@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, 2026
@risikatpopoola risikatpopoola removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Aug 19, 2026
@risikatpopoola risikatpopoola added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 19, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good.

}
}

bookForm.addEventListener("submit", addBook);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could consider placing all code that runs once on page load in a single function. For example, you could put it inside the page load callback or create a function named init() or setup() and call it once when the page loads.

This makes it easier to locate and manage all the code that runs once when the app starts.

@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, 2026
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. Module-Data-Flows The name of the module. 🏕 Priority Mandatory This work is expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants