From abb1775bd6d3983b23554053ebe1c6dd8335a594 Mon Sep 17 00:00:00 2001 From: OBakir90 <53667329+OBakir90@users.noreply.github.com> Date: Fri, 26 Jun 2020 21:21:15 +0100 Subject: [PATCH] done debugging --- .../0-thinking-like-a-programmer/task.md | 5 + .../mandatory/1-debugging-practice/index.html | 143 +++++++----------- .../mandatory/1-debugging-practice/script.js | 14 +- 3 files changed, 68 insertions(+), 94 deletions(-) diff --git a/week-7/Homework/mandatory/0-thinking-like-a-programmer/task.md b/week-7/Homework/mandatory/0-thinking-like-a-programmer/task.md index 1c841f8d5..bfada3ffe 100644 --- a/week-7/Homework/mandatory/0-thinking-like-a-programmer/task.md +++ b/week-7/Homework/mandatory/0-thinking-like-a-programmer/task.md @@ -27,11 +27,16 @@ After you've watched these videos I'd like you to answer these questions ## 1. What do you think the most important quality for a programmer is? +to be able to work systematically +problem solving (determining the problem, making search to find the ways and implementing to the case) + ## 2. When trying to solve a challenge, what should you do first? +I do seperate the tasks to parts and carry on step by step ## 3. What should you do if you get stuck? +I use debugging. if still doesnt work i do some search and still cant sort it out ask someone else \ No newline at end of file diff --git a/week-7/Homework/mandatory/1-debugging-practice/index.html b/week-7/Homework/mandatory/1-debugging-practice/index.html index 23acfa71e..0fb3eda69 100644 --- a/week-7/Homework/mandatory/1-debugging-practice/index.html +++ b/week-7/Homework/mandatory/1-debugging-practice/index.html @@ -1,96 +1,63 @@ - - - - - - - - - - -
-

Library

-

Add books to your virtual library

-
+ + + + + + + + + + + +
+

Library

+

Add books to your virtual library

+
- + -
-
- - - - - - - - -
+
+
+ + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
TitleAuthorNumber of PagesRead
- - - - - - - - - - - - - - - - - - - -
TitleAuthorNumber of PagesRead
+ + - - - + \ No newline at end of file diff --git a/week-7/Homework/mandatory/1-debugging-practice/script.js b/week-7/Homework/mandatory/1-debugging-practice/script.js index dc14a775a..89e2d9aa6 100644 --- a/week-7/Homework/mandatory/1-debugging-practice/script.js +++ b/week-7/Homework/mandatory/1-debugging-practice/script.js @@ -29,6 +29,8 @@ const check = document.getElementById("check"); //via Book function and start render function function submit() { if ( + author.value == null || + author.value == "" || title.value == null || title.value == "" || pages.value == null || @@ -37,8 +39,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(); } } @@ -54,7 +56,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 @@ -76,7 +78,7 @@ function render() { changeBut.className = "btn btn-success"; cell4.appendChild(changeBut); let readStatus = ""; - if (myLibrary[i].check == false) { + if (myLibrary[i].check == true) { readStatus = "Yes"; } else { readStatus = "No"; @@ -89,12 +91,12 @@ 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; cell5.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();