From 32cd65eb61f4d1470735a38dbe2c064ff1c53e90 Mon Sep 17 00:00:00 2001 From: CJ Yuan Date: Tue, 6 May 2025 14:44:56 +0100 Subject: [PATCH 01/15] Update pull_request_template.md (#223) --- .github/pull_request_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ae4e1977..108898f0 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,11 +2,11 @@ You must title your PR like this: -COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK +REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME For example, -NW4 | Carol Owen | HTML-CSS-Module | Week1 +London | May-2025 | Carol Owen | Sprint-1 Complete the task list below this message. If your PR is rejected, check the task list. @@ -18,7 +18,7 @@ If your PR is rejected, check the task list. Self checklist - [ ] I have committed my files one by one, on purpose, and for a reason -- [ ] I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK +- [ ] I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME - [ ] I have tested my changes - [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/contributing/) - [ ] My changes meet the [requirements](./README.md) of this task From f71f87a30dc825025c8ac1fa4a908bdd066e01d3 Mon Sep 17 00:00:00 2001 From: CJ Yuan Date: Tue, 8 Jul 2025 01:04:46 +0100 Subject: [PATCH 02/15] Fix the link to Style Guide in PR template --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 108898f0..c8695304 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -20,8 +20,8 @@ Self checklist - [ ] I have committed my files one by one, on purpose, and for a reason - [ ] I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME - [ ] I have tested my changes -- [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/contributing/) -- [ ] My changes meet the [requirements](./README.md) of this task +- [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/) +- [ ] My changes meet the requirements of this task ## Changelist From 050beedb72dbe15158243d53d2ab249391a73a25 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 14 Jul 2025 16:28:18 +0100 Subject: [PATCH 03/15] Update repo metadata --- .github/FUNDING.yml | 11 ---- .github/ISSUE_TEMPLATE/config.yml | 4 +- .github/ISSUE_TEMPLATE/pd-assignment.yml | 2 +- .github/ISSUE_TEMPLATE/tech-ed-assignment.yml | 32 +++++++----- .github/pull_request_template.md | 8 +-- HOW_TO_REVIEW.md | 52 ------------------- 6 files changed, 27 insertions(+), 82 deletions(-) delete mode 100644 HOW_TO_REVIEW.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index b34cfcfc..ea03447f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,13 +1,2 @@ -# These are supported funding model platforms - github: CodeYourFuture -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry custom: https://codeyourfuture.io/donate diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5fe8ffd0..db0e6f43 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,4 @@ -blank_issues_enabled: false +blank_issues_enabled: true contact_links: - name: CYF url: contact@codeyourfuture.io @@ -8,7 +8,7 @@ contact_links: about: Join CYF here - name: CYF Slack url: codeyourfuture.slack.com - about: Come to #cyf-syllabus-tech and chat + about: Come to #cyf-curriculum and chat - name: CYF Tech Ed url: https://github.com/orgs/CodeYourFuture/teams/mentors about: CYF mentors on Github diff --git a/.github/ISSUE_TEMPLATE/pd-assignment.yml b/.github/ISSUE_TEMPLATE/pd-assignment.yml index c8bd2298..19f15fa3 100644 --- a/.github/ISSUE_TEMPLATE/pd-assignment.yml +++ b/.github/ISSUE_TEMPLATE/pd-assignment.yml @@ -1,7 +1,7 @@ name: PD Coursework description: Assign a piece of PD coursework title: "[PD] " -labels: [PD, 🏝 Priority Stretch, 🐇 Size Small] +labels: [PD, 🏝 Priority Stretch, 🐇 Size Small, 📅 Sprint 1] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/tech-ed-assignment.yml b/.github/ISSUE_TEMPLATE/tech-ed-assignment.yml index 1bdba293..343b4d67 100644 --- a/.github/ISSUE_TEMPLATE/tech-ed-assignment.yml +++ b/.github/ISSUE_TEMPLATE/tech-ed-assignment.yml @@ -1,26 +1,34 @@ name: Tech Ed Coursework description: Assign a piece of technical coursework -title: "[TECH ED] <title>" -labels: [Tech Ed, 🏕 Priority Mandatory, 🐂 Size Medium] +title: "<title>" +labels: [Tech Ed, 🏕 Priority Mandatory, 🐂 Size Medium, 📅 Sprint 1] body: - type: markdown attributes: value: | - Thanks for taking the time to assign this coursework! + Thanks for taking the time to assign this coursework! - To support our trainees with planning and prioritising their own learning journey, we want our coursework assignments to be more informative. + To support our trainees with planning and prioritising their own learning journey, we want our coursework assignments to be more informative. We don't just want to tell them what to do, we want to tell them stuff like: - why we are doing it - what it's "for" (problem-solving, debugging, etc) - how long they should spend on it, maximum - - how to get help - - how to review it with answers + - how to get help + - how to review it with answers - how to get it reviewed from mentors and peers - type: input attributes: label: Link to the coursework validations: required: true + - type : textarea + attributes: + label: Learning Objectives + description: https://common.codeyourfuture.io/common-theme/shortcodes/objectives/ + placeholder: | + <!--{{<objectives}}--> + - [ ] CYF format, task list formatting + <!--{{</objectives}}--> - type: textarea attributes: label: Why are we doing this? @@ -37,14 +45,14 @@ body: attributes: label: How to get help description: State simply how trainees can get help with this assignment - placeholder: | + value: | Share your blockers in your class channel - https://syllabus.codeyourfuture.io/guides/asking-questions + https://curriculum.codeyourfuture.io/guides/getting-help/asking-questions/ - type: textarea attributes: label: How to submit description: State in clear steps how a trainee can submit this assignment. - placeholder: | + value: | Fork the repo to your own GitHub account Make regular small commits with clear messages When you are ready, open a Pull Request to the CYF repo @@ -72,9 +80,9 @@ body: 1. Update labels - priority -- is this coursework key, mandatory, or stretch? Pick one. - size -- help trainees plan their time with rough estimation. Pick one - - topics -- add all that seem relevant to you. - 2. Add to milestone - - week 1,2,3,4 + - topics -- add all that seem relevant to you. + 2. Add a Sprint label to add to the backlog view + - sprint 1,2,3,4 Once your ticket is complete, you may like to add it to the example project board attached to this repo. This is so you understand how trainees will use your work. Nobody has built a board copier yet, so trainees will be doing this step themselves. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c8695304..86544e40 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,11 +2,11 @@ You must title your PR like this: -REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME +Region | Cohort | FirstName LastName | Sprint | Assignment Title For example, -London | May-2025 | Carol Owen | Sprint-1 +London | 25-ITP-May | Carol Owen | Sprint 1 | Alarm Clock Complete the task list below this message. If your PR is rejected, check the task list. @@ -18,10 +18,10 @@ If your PR is rejected, check the task list. Self checklist - [ ] I have committed my files one by one, on purpose, and for a reason -- [ ] I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME +- [ ] I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title - [ ] I have tested my changes - [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/) -- [ ] My changes meet the requirements of this task +- [ ] My changes meet the [requirements](./README.md) of this task ## Changelist diff --git a/HOW_TO_REVIEW.md b/HOW_TO_REVIEW.md deleted file mode 100644 index fd7820a1..00000000 --- a/HOW_TO_REVIEW.md +++ /dev/null @@ -1,52 +0,0 @@ -# Everyone reviews code at CYF - -https://curriculum.codeyourfuture.io/guides/reviewing/ - -Mentors and trainees all review code, and collaborate on improving code quality. We are all helping each other to talk, write, and think about code more clearly. - -We are not reviewing code as if we were to merge this PR into production; we are opening a technical conversation for the purpose of insight and development. - -## Key points: - -1. Ask questions instead of making statements: - - **YES:** "Is there another element you could use to group a set of fields in a form? Why might someone use a different element in a form?" - **NO:** "Use fieldset not divs" - -2. Encourage simplicity, clarity, and precision: - - **YES** "There are 15,0000 files in this changelist. Which files should be reviewed?" - **NO** "It doesn't matter; I can try to figure out what you meant." - -3. Respect everyone's work and time: - - **YES** "I think there's some more to do here. Thanks for sharing where you're up to." - **NO** "This is rubbish. Try harder." - -## Labels - -Reviewers, please add labels (provided) to the PR once you've reviewed. This helps to focus the trainee on the areas they should work on, and gives an overview for mentors on what the whole cohort needs to work on. - -## Solutions - -### Where to find solutions? - -You can find the solutions for the module on the `solutions` branch. - -### Solutions branch - -The solutions branch typically contains: - -#### Sample solutions - -Solutions are example answers not the only correct answers. - -#### Common responses guides. - -Everyone is invited to contribute commonly encountered problems, mistakes, misunderstandings, and mental-model errors to our common responses documents. - -Use these resources to inform your code review, get unstuck, and improve your understanding. - -## Guides - -https://curriculum.codeyourfuture.io/guides/reviewing/ From d3c51c0dc3fee62f403fe9088e40f8bc3dae665d Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall <dawagner@gmail.com> Date: Wed, 13 Aug 2025 20:36:12 +0100 Subject: [PATCH 04/15] Set up Validate PR Metadata action --- .github/workflows/validate-pr-metadata.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/validate-pr-metadata.yml diff --git a/.github/workflows/validate-pr-metadata.yml b/.github/workflows/validate-pr-metadata.yml new file mode 100644 index 00000000..10ef3c74 --- /dev/null +++ b/.github/workflows/validate-pr-metadata.yml @@ -0,0 +1,18 @@ +name: Validate PR Metadata +on: + pull_request_target: + types: + - labeled + - unlabeled + - opened + - edited + - reopened + +jobs: + validate_pr_metadata: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: CodeYourFuture/actions/validate-pr-metadata@main + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 282246ff9f2c4fa6ac8b5cf1bafab349908bc077 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall <dawagner@gmail.com> Date: Wed, 27 Aug 2025 11:07:23 +0100 Subject: [PATCH 05/15] Update PR template --- .github/pull_request_template.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 86544e40..0d8ee1df 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,8 +8,13 @@ For example, London | 25-ITP-May | Carol Owen | Sprint 1 | Alarm Clock -Complete the task list below this message. -If your PR is rejected, check the task list. +Fill in the template below - remove any sections that don't apply. + +Complete the self checklist - replace each empty box in the checklist [ ] with a [x]. + +Add the label "Needs Review" and you will get review. + +Respond to volunteer reviews until the volunteer marks it as "Complete". --> @@ -17,11 +22,10 @@ If your PR is rejected, check the task list. 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 +- [ ] My changes meet the requirements of the task - [ ] I have tested my changes - [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/) -- [ ] My changes meet the [requirements](./README.md) of this task ## Changelist From 031e3435f4ebb19a51e2013d2ba7718f912a9e9b Mon Sep 17 00:00:00 2001 From: Poonam Rajput <poonam@codeyourfuture.io> Date: Fri, 28 Nov 2025 11:39:21 +0000 Subject: [PATCH 06/15] basic deadcode exercise structure --- Sprint-3/dead-code/README.md | 0 Sprint-3/dead-code/exercise-1.js | 0 Sprint-3/dead-code/exercise-2.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Sprint-3/dead-code/README.md create mode 100644 Sprint-3/dead-code/exercise-1.js create mode 100644 Sprint-3/dead-code/exercise-2.js diff --git a/Sprint-3/dead-code/README.md b/Sprint-3/dead-code/README.md new file mode 100644 index 00000000..e69de29b diff --git a/Sprint-3/dead-code/exercise-1.js b/Sprint-3/dead-code/exercise-1.js new file mode 100644 index 00000000..e69de29b diff --git a/Sprint-3/dead-code/exercise-2.js b/Sprint-3/dead-code/exercise-2.js new file mode 100644 index 00000000..e69de29b From 2547e09114c34a7fba95a290076c1ee283ec6ce0 Mon Sep 17 00:00:00 2001 From: Poonam Rajput <poonam@codeyourfuture.io> Date: Fri, 28 Nov 2025 12:06:46 +0000 Subject: [PATCH 07/15] dead code backlog exercises and readme --- Sprint-3/dead-code/README.md | 11 +++++++++++ Sprint-3/dead-code/exercise-1.js | 19 +++++++++++++++++++ Sprint-3/dead-code/exercise-2.js | 27 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/Sprint-3/dead-code/README.md b/Sprint-3/dead-code/README.md index e69de29b..a3507c6c 100644 --- a/Sprint-3/dead-code/README.md +++ b/Sprint-3/dead-code/README.md @@ -0,0 +1,11 @@ +# Refactoring Dead Code + +Here are two example of code that has not been built efficiently. Both files have dead code in them, it's your job to go back through this existing code, identify the dead code, and remove it so the code is ready for production. + +## Instructions + +1. Work through each `exercise` file inside this directory. +2. Delete the dead code. +3. Commit your changes and make a PR when done. + + diff --git a/Sprint-3/dead-code/exercise-1.js b/Sprint-3/dead-code/exercise-1.js index e69de29b..95bc4d30 100644 --- a/Sprint-3/dead-code/exercise-1.js +++ b/Sprint-3/dead-code/exercise-1.js @@ -0,0 +1,19 @@ +// Find the instances of unreachable and redundant code - remove them! + +let testName = 'Jerry' +const greeting = 'hello' + +function sayHello(greeting, name) { + const greetingStr = greeting + ', ' + name + '!' + return `${greeting}, ${name}!` + console.log(greetingStr) + } + +testName = 'Aman' + +const greetingMessage = sayHello(greeting, testName) + +console.log(greetingMessage) // 'hello, Aman!' + + + diff --git a/Sprint-3/dead-code/exercise-2.js b/Sprint-3/dead-code/exercise-2.js index e69de29b..8558b6f0 100644 --- a/Sprint-3/dead-code/exercise-2.js +++ b/Sprint-3/dead-code/exercise-2.js @@ -0,0 +1,27 @@ +// Remove the unused code that does not contribute to the final console log + +const pets = ['parrot', 'hamster', 'horse', 'dog', 'hamster','cat', 'hamster'] +const capitalisedPets = pets.map((pet) => pet.toUpperCase()) +const petsStartingWithH = pets.filter((pet) => pet[0] === 'h') + +function logPets(petsArr){ + petsArr.forEach((pet) => console.log(pet)) +} + +function countAndCapitalisePets(petsArr){ + const petCount = {} + + petsArr.forEach((pet) => { + const capitalisedPet = pet.toUpperCase() + if(petCount[capitalisedPet]){ + petCount[capitalisedPet] += 1 + } else { + petCount[capitalisedPet] = 1 + } + }) + return petCount +} + +const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH) + +console.log(countedPetsStartingWithH) // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log \ No newline at end of file From 052c3a91f78f2872fec092367f94f3f7d9768889 Mon Sep 17 00:00:00 2001 From: Poonam Rajput <poonam@codeyourfuture.io> Date: Tue, 2 Dec 2025 12:02:33 +0000 Subject: [PATCH 08/15] prettier-ified all files --- Sprint-3/dead-code/README.md | 6 ++---- Sprint-3/dead-code/exercise-1.js | 21 ++++++++----------- Sprint-3/dead-code/exercise-2.js | 36 ++++++++++++++++---------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/Sprint-3/dead-code/README.md b/Sprint-3/dead-code/README.md index a3507c6c..785101d3 100644 --- a/Sprint-3/dead-code/README.md +++ b/Sprint-3/dead-code/README.md @@ -5,7 +5,5 @@ Here are two example of code that has not been built efficiently. Both files hav ## Instructions 1. Work through each `exercise` file inside this directory. -2. Delete the dead code. -3. Commit your changes and make a PR when done. - - +2. Delete the dead code. +3. Commit your changes and make a PR when done. diff --git a/Sprint-3/dead-code/exercise-1.js b/Sprint-3/dead-code/exercise-1.js index 95bc4d30..6077b36f 100644 --- a/Sprint-3/dead-code/exercise-1.js +++ b/Sprint-3/dead-code/exercise-1.js @@ -1,19 +1,16 @@ // Find the instances of unreachable and redundant code - remove them! -let testName = 'Jerry' -const greeting = 'hello' +let testName = "Jerry"; +const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ', ' + name + '!' - return `${greeting}, ${name}!` - console.log(greetingStr) - } - -testName = 'Aman' - -const greetingMessage = sayHello(greeting, testName) - -console.log(greetingMessage) // 'hello, Aman!' + const greetingStr = greeting + ", " + name + "!"; + return `${greeting}, ${name}!`; + console.log(greetingStr); +} +testName = "Aman"; +const greetingMessage = sayHello(greeting, testName); +console.log(greetingMessage); // 'hello, Aman!' diff --git a/Sprint-3/dead-code/exercise-2.js b/Sprint-3/dead-code/exercise-2.js index 8558b6f0..df0e3b45 100644 --- a/Sprint-3/dead-code/exercise-2.js +++ b/Sprint-3/dead-code/exercise-2.js @@ -1,27 +1,27 @@ // Remove the unused code that does not contribute to the final console log -const pets = ['parrot', 'hamster', 'horse', 'dog', 'hamster','cat', 'hamster'] -const capitalisedPets = pets.map((pet) => pet.toUpperCase()) -const petsStartingWithH = pets.filter((pet) => pet[0] === 'h') +const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; +const capitalisedPets = pets.map((pet) => pet.toUpperCase()); +const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr){ - petsArr.forEach((pet) => console.log(pet)) +function logPets(petsArr) { + petsArr.forEach((pet) => console.log(pet)); } -function countAndCapitalisePets(petsArr){ - const petCount = {} +function countAndCapitalisePets(petsArr) { + const petCount = {}; - petsArr.forEach((pet) => { - const capitalisedPet = pet.toUpperCase() - if(petCount[capitalisedPet]){ - petCount[capitalisedPet] += 1 - } else { - petCount[capitalisedPet] = 1 - } - }) - return petCount + petsArr.forEach((pet) => { + const capitalisedPet = pet.toUpperCase(); + if (petCount[capitalisedPet]) { + petCount[capitalisedPet] += 1; + } else { + petCount[capitalisedPet] = 1; + } + }); + return petCount; } -const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH) +const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); -console.log(countedPetsStartingWithH) // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log \ No newline at end of file +console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log From 4136ae2f13f6cc90faf5414605cff0be689b88cb Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 21:55:50 +0000 Subject: [PATCH 09/15] Fix syntax error in render loop preventing initial render --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 75ce6c1d..eed706fd 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -54,7 +54,7 @@ function render() { let table = document.getElementById("display"); let rowsNumber = table.rows.length; //delete old table - for (let n = rowsNumber - 1; n > 0; n-- { + for (let n = rowsNumber - 1; n > 0; n--) { table.deleteRow(n); } //insert updated row and cells From 478a62d547b6a4b64176b756572660e58d172d91 Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 22:01:15 +0000 Subject: [PATCH 10/15] Fix delete button variable name causing render crash --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index eed706fd..abcd4293 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -89,7 +89,7 @@ function render() { }); //add delete button to every row and render again - let delButton = document.createElement("button"); + let delBut = document.createElement("button"); delBut.id = i + 5; deleteCell.appendChild(delBut); delBut.className = "btn btn-warning"; From 4843708d352e903a1a7301887aa3a8f80461a275 Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 22:13:42 +0000 Subject: [PATCH 11/15] Fix author field when creating new Book from form input --- debugging/book-library/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index abcd4293..f95d0887 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,8 +37,8 @@ function submit() { 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); + myLibrary.push(book); render(); } } From ab5513e3c8ef0f8b1d642d63e25512c8914a1157 Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 22:17:28 +0000 Subject: [PATCH 12/15] Fix read status logic when rendering books --- debugging/book-library/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index f95d0887..ec931adf 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -77,9 +77,9 @@ function render() { wasReadCell.appendChild(changeBut); let readStatus = ""; if (myLibrary[i].check == false) { - readStatus = "Yes"; - } else { readStatus = "No"; + } else { + readStatus = "Yes"; } changeBut.innerText = readStatus; From 1fb857774746603cac3babbffc057f5ac1d4ff57 Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 22:19:54 +0000 Subject: [PATCH 13/15] Fix delete button by using correct click event listener --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index ec931adf..098c74ec 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -94,7 +94,7 @@ function render() { deleteCell.appendChild(delBut); delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delBut.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From 610f0ce9a4f7c98e4e4d508847b438591544ed36 Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 23:34:58 +0000 Subject: [PATCH 14/15] Clear form fields after successful book submission --- debugging/book-library/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 098c74ec..b800834b 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -40,6 +40,12 @@ function submit() { let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); + + //clear the form after submit + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; } } From 6acbd7c58634f06dd1a691c91a54c1a177f5d1ac Mon Sep 17 00:00:00 2001 From: Konvaly <konvaly@gmail.com> Date: Tue, 16 Dec 2025 23:42:37 +0000 Subject: [PATCH 15/15] Prevent adding duplicate books by title --- debugging/book-library/script.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index b800834b..5032b51d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,17 +37,24 @@ function submit() { alert("Please fill all fields!"); return false; } else { + const alreadyExists = myLibrary.some( + (book) => book.title === title.value); + if (alreadyExists) { + alert("This book is already in your library!"); + return; + } + } let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); - + //clear the form after submit title.value = ""; author.value = ""; pages.value = ""; check.checked = false; } -} + function Book(title, author, pages, check) { this.title = title;