Skip to content

Conversation

JenniferIsidienu
Copy link

@JenniferIsidienu JenniferIsidienu commented Aug 19, 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.

Questions

Ask any questions you have for your reviewer.

@JenniferIsidienu JenniferIsidienu added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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.

  • Can you change the base branch of this PR from CYF's book-library to CYF's main?
image

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 20, 2025
@JenniferIsidienu JenniferIsidienu changed the base branch from Book-Library to main August 20, 2025 08:15
@JenniferIsidienu
Copy link
Author

Thank you. I've changed to CYF main. I'll go through the general feedback to see where I can improve my code.
I appreciate the guidance.

@JenniferIsidienu JenniferIsidienu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 20, 2025
@kfklein15 kfklein15 requested a review from cjyuan August 20, 2025 10:46
) {
alert("Please fill all fields!");
return false;
} else {
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
let book = new Book(title.value, author.value, pages.value, check.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Do you want to keep leading and trailing space characters in title and author?

  • pages.value is a string, and it can be any string value accepted by the <input type="number"> element.

  • Consider pre-process/sanitize/normalize input and store them in some variables first, and reference the variables in other parts of the function.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, I will make the corrections.

delBut.addEventListener("clicks", function () {
alert(`You've deleted title: ${myLibrary[i].title}`);
// Delete button
let deleteCell = row.insertCell(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Author

Choose a reason for hiding this comment

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

Keeping it in one location will make it easier to read. I'll correct mine.

Copy link
Contributor

Choose a reason for hiding this comment

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

By "keeping all cell creation code in one location", I meant

    row.insertCell(0).innerText = book.title;
    row.insertCell(1).innerText = book.author;
    row.insertCell(2).innerText = book.pages;
    
    // Could use const instead of let
    const readCell = row.insertCell(3);        
    const deleteCell = row.insertCell(4);
    
    ...

This way, it is easy to find out there are 5 cells created.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 20, 2025
@JenniferIsidienu JenniferIsidienu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 20, 2025
delBut.addEventListener("clicks", function () {
alert(`You've deleted title: ${myLibrary[i].title}`);
// Delete button
let deleteCell = row.insertCell(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

By "keeping all cell creation code in one location", I meant

    row.insertCell(0).innerText = book.title;
    row.insertCell(1).innerText = book.author;
    row.insertCell(2).innerText = book.pages;
    
    // Could use const instead of let
    const readCell = row.insertCell(3);        
    const deleteCell = row.insertCell(4);
    
    ...

This way, it is easy to find out there are 5 cells created.

}

let book = new Book(trimmedTitle, trimmedAuthor, pagesNumber, check.checked);
Copy link
Contributor

Choose a reason for hiding this comment

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

pageNumber could be a value like 3.1416.

@cjyuan
Copy link
Contributor

cjyuan commented Aug 20, 2025

Changes are good. Code could still be improved but I am sure you can easily fix them.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 20, 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.

2 participants