From 19f152991589183763e3448fa58b44d250001787 Mon Sep 17 00:00:00 2001 From: AbdihamidAli Date: Fri, 3 May 2024 09:23:40 +0100 Subject: [PATCH 1/3] debugged and tested --- book-library/index.html | 4 ++-- book-library/script.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/book-library/index.html b/book-library/index.html index 23acfa71..31afed3c 100644 --- a/book-library/index.html +++ b/book-library/index.html @@ -1,7 +1,7 @@ - + - + Book Library 0; n-- { + for (let n = rowsNumber - 1; n > 0; n--) { table.deleteRow(n); } //insert updated row and cells @@ -90,11 +90,11 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); - delBut.id = i + 5; - cell5.appendChild(delBut); - delBut.className = "btn btn-warning"; - delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delButton.id = i + 5; + cell5.appendChild(delButton); // Changed from 'delBut' + delButton.className = "btn btn-warning"; // Changed from 'delBut' + delButton.innerHTML = "Delete"; // Changed from 'delBut' + delButton.addEventListener("click", function () { // Fixed event listener name alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From a625dcaee8c08bbff2d95816272fec01701d6de7 Mon Sep 17 00:00:00 2001 From: AbdihamidAli Date: Fri, 3 May 2024 09:39:59 +0100 Subject: [PATCH 2/3] fixed if statement --- book-library/script.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/book-library/script.js b/book-library/script.js index c9903372..af59afac 100644 --- a/book-library/script.js +++ b/book-library/script.js @@ -75,12 +75,7 @@ function render() { changeBut.id = i; changeBut.className = "btn btn-success"; cell4.appendChild(changeBut); - let readStatus = ""; - if (myLibrary[i].check == false) { - readStatus = "Yes"; - } else { - readStatus = "No"; - } + let readStatus = myLibrary[i].check ? "No" : "Yes"; // Fix for displaying correct read status changeBut.innerHTML = readStatus; changeBut.addEventListener("click", function () { From 71b4d1148039a94cb079fb91f03983d828f0e349 Mon Sep 17 00:00:00 2001 From: AbdihamidAli Date: Mon, 6 May 2024 02:04:29 +0100 Subject: [PATCH 3/3] trying to make it pass the analysis --- book-library/script.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/book-library/script.js b/book-library/script.js index af59afac..b2dd0a93 100644 --- a/book-library/script.js +++ b/book-library/script.js @@ -75,7 +75,7 @@ function render() { changeBut.id = i; changeBut.className = "btn btn-success"; cell4.appendChild(changeBut); - let readStatus = myLibrary[i].check ? "No" : "Yes"; // Fix for displaying correct read status + let readStatus = myLibrary[i].check ? "No" : "Yes"; changeBut.innerHTML = readStatus; changeBut.addEventListener("click", function () { @@ -84,12 +84,12 @@ function render() { }); //add delete button to every row and render again - let delButton = document.createElement("button"); - delButton.id = i + 5; - cell5.appendChild(delButton); // Changed from 'delBut' - delButton.className = "btn btn-warning"; // Changed from 'delBut' - delButton.innerHTML = "Delete"; // Changed from 'delBut' - delButton.addEventListener("click", function () { // Fixed event listener name + let delBut = document.createElement("button"); + delBut.id = i + 5; + cell5.appendChild(delBut); + delBut.className = "btn btn-warning"; + delBut.innerHTML = "Delete"; + delBut.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render();