Skip to content

Commit 784e45d

Browse files
committed
fixed boolean comparision to false == "No"
1 parent bc252e6 commit 784e45d

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

debugging/book-library/script.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ function render() {
7676
changeBut.className = "btn btn-success";
7777
wasReadCell.appendChild(changeBut);
7878
let readStatus = "";
79-
if (myLibrary[i].check == false) {
80-
readStatus = "Yes";
81-
} else {
79+
if (myLibrary[i].check == "false") {
8280
readStatus = "No";
81+
} else {
82+
readStatus = "Yes";
8383
}
8484
changeBut.innerText = readStatus;
8585

@@ -88,6 +88,29 @@ function render() {
8888
render();
8989
});
9090

91+
92+
// second option to booleans comparisons
93+
// let changeBut = document.createElement("button");
94+
// changeBut.id = i;
95+
// changeBut.className = "btn btn-success";
96+
// wasReadCell.appendChild(changeBut);
97+
// let readStatus = "";
98+
99+
// // Directly check for boolean value (true or false)
100+
// if (myLibrary[i].check == false) {
101+
// readStatus = "No";
102+
// } else {
103+
// readStatus = "Yes";
104+
// }
105+
106+
// changeBut.innerText = readStatus;
107+
108+
// changeBut.addEventListener("click", function () {
109+
// myLibrary[i].check = !myLibrary[i].check; // Toggle the read status
110+
// render();
111+
// });
112+
113+
91114
//add delete button to every row and render again
92115
let delButton = document.createElement("button");
93116
delBut.id = i + 5;

0 commit comments

Comments
 (0)