Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions week-1/Homework/mandatory/0-thinking-like-a-programmer/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ 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?

<!-- Write your answer here -->
<!--
Abstraction and Problem-solving skills. Abstraction gives the programmer a great advantage of deducing solutions to new problems from previous solutions that the programmer is used to. Because it is very hard to just brute force your way and memorize different solutions to different problems you have to sharp your Abstraction skills.
-->

## 2. When trying to solve a challenge, what should you do first?

<!-- Write your answer here -->
<!--
First understand the problem clearly to do that.
Try to explain it out loud as if you were talking to a someone else.

-->

## 3. What should you do if you get stuck?

<!-- Write your answer here -->
<!--
Thinking about what you told the computer to do as opposed to what you want it to do.
A good way to do that is to divide the problem into small manageable units of code and study each unit of code a lone.
-->
19 changes: 11 additions & 8 deletions week-1/Homework/mandatory/1-debugging-practice/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

let myLibrary = [];

window.addEventListener("load", function (e) {
Expand Down Expand Up @@ -32,13 +33,15 @@ function submit() {
title.value == null ||
title.value == "" ||
pages.value == null ||
pages.value == ""
pages.value == "" ||
author.value == null ||
author.value == ""
) {
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();
}
}
Expand All @@ -54,12 +57,12 @@ 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
let length = myLibrary.length;
for (let i = 0; i < length; i++) {
for (let i = 0; i < length; i++) {
let row = table.insertRow(1);
let cell1 = row.insertCell(0);
let cell2 = row.insertCell(1);
Expand All @@ -76,7 +79,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";
Expand All @@ -89,12 +92,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();
Expand Down