Skip to content

Commit bc252e6

Browse files
authored
Some fixes to the book project (#94)
* Fix some not glorious naming ("let cell1 = row.insertCell(0);") * Use innerText not innerHTML
1 parent ed76b80 commit bc252e6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

debugging/book-library/script.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,27 @@ function render() {
6161
let length = myLibrary.length;
6262
for (let i = 0; i < length; i++) {
6363
let row = table.insertRow(1);
64-
let cell1 = row.insertCell(0);
65-
let cell2 = row.insertCell(1);
66-
let cell3 = row.insertCell(2);
67-
let cell4 = row.insertCell(3);
68-
let cell5 = row.insertCell(4);
69-
cell1.innerHTML = myLibrary[i].title;
70-
cell2.innerHTML = myLibrary[i].author;
71-
cell3.innerHTML = myLibrary[i].pages;
64+
let titleCell = row.insertCell(0);
65+
let authorCell = row.insertCell(1);
66+
let pagesCell = row.insertCell(2);
67+
let wasReadCell = row.insertCell(3);
68+
let deleteCell = row.insertCell(4);
69+
titleCell.innerHTML = myLibrary[i].title;
70+
authorCell.innerHTML = myLibrary[i].author;
71+
pagesCell.innerHTML = myLibrary[i].pages;
7272

7373
//add and wait for action for read/unread button
7474
let changeBut = document.createElement("button");
7575
changeBut.id = i;
7676
changeBut.className = "btn btn-success";
77-
cell4.appendChild(changeBut);
77+
wasReadCell.appendChild(changeBut);
7878
let readStatus = "";
7979
if (myLibrary[i].check == false) {
8080
readStatus = "Yes";
8181
} else {
8282
readStatus = "No";
8383
}
84-
changeBut.innerHTML = readStatus;
84+
changeBut.innerText = readStatus;
8585

8686
changeBut.addEventListener("click", function () {
8787
myLibrary[i].check = !myLibrary[i].check;
@@ -91,7 +91,7 @@ function render() {
9191
//add delete button to every row and render again
9292
let delButton = document.createElement("button");
9393
delBut.id = i + 5;
94-
cell5.appendChild(delBut);
94+
deleteCell.appendChild(delBut);
9595
delBut.className = "btn btn-warning";
9696
delBut.innerHTML = "Delete";
9797
delBut.addEventListener("clicks", function () {

0 commit comments

Comments
 (0)