From c3ea079516c7a50dcb21a2364f97e0edbc681b95 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:50:50 +0200 Subject: [PATCH 01/14] complete exercises 1 to 6 --- debugging/demo/demo1/demo1.js | 53 ++++++++++++++++++++--------------- errors/exercise1.js | 4 +-- errors/exercise2.js | 11 ++++---- errors/exercise3.js | 2 +- errors/exercise4.js | 4 +-- errors/exercise5.js | 2 +- errors/exercise6.js | 8 +++--- 7 files changed, 46 insertions(+), 38 deletions(-) diff --git a/debugging/demo/demo1/demo1.js b/debugging/demo/demo1/demo1.js index 0d8e695..2cbce39 100644 --- a/debugging/demo/demo1/demo1.js +++ b/debugging/demo/demo1/demo1.js @@ -1,35 +1,42 @@ -const tomatoes = 'tomatoes'; -const chocolate= 'chocolate'yummy'; -const yogurt = 'yogurt'; +const tomatoes = "tomatoes"; +const chocolate = "chocolate yummy"; +const yogurt = "yogurt"; const rice = "rice"; -const fridge =[{ item: tomatoes, quantity: 5}, - { item: chocolate, quantity: 1}, - { item: yogurt, quantity: 5}]; +const fridge = [ + { item: tomatoes, quantity: 5 }, + { item: chocolate, quantity: 1 }, + { item: yogurt, quantity: 5 }, +]; -const wantedList = [{ item: tomatoes, quantity: 4}, - { item: chocolate, quantity: 10}, - { item: yogurt, quantity: 2}] +const wantedList = [ + { item: tomatoes, quantity: 4 }, + { item: chocolate, quantity: 10 }, + { item: yogurt, quantity: 2 }, +]; const shoppingList = (fridge, wantedList) => { - return wantedList.map(groceryWantedList => { - let groceryFridge = fridge.find( gf => gf.item === groceryWantedList.item); - if (groceryFridge===null){ + return wantedList + .map((groceryWantedList) => { + let groceryFridge = fridge.find( + (gf) => gf.item === groceryWantedList.item + ); + if (groceryFridge === null) { return groceryWantedList; } else { - if (groceryFridge.quantity < groceryWantedList.quantity){ + if (groceryFridge.quantity < groceryWantedList.quantity) { return { - item: groceryWantedList.item, - quantity: groceryWantedList.quantity - groceryFridge.quantity + item: groceryWantedList.item, + quantity: groceryWantedList.quantity - groceryFridge.quantity, }; - } - else{ - return null; + } else { + return null; + } } - } - }).filter(item => item !== null); + }) + .filter((item) => item !== null); }; -shoppingList (fridge, wantedList).forEach( (item) => { - console.log (`${item.item}: ${item.quantity}`); - }) \ No newline at end of file +shoppingList(fridge, wantedList).forEach((item) => { + console.log(`${item.item}: ${item.quantity}`); +}); diff --git a/errors/exercise1.js b/errors/exercise1.js index 6adfa43..5834b50 100644 --- a/errors/exercise1.js +++ b/errors/exercise1.js @@ -1,3 +1,3 @@ -if (3 > Math.PI { - console.log("wait what?"); +if (3 > Math.PI) { + console.log("wait what?"); } diff --git a/errors/exercise2.js b/errors/exercise2.js index da8708f..bc748c8 100644 --- a/errors/exercise2.js +++ b/errors/exercise2.js @@ -1,6 +1,7 @@ -let charge = function() { - if (sunny) { - useSolarCells(); - } else { - promptBikeRide(); +let charge = function () { + if (sunny) { + useSolarCells(); + } else { + promptBikeRide(); + } }; diff --git a/errors/exercise3.js b/errors/exercise3.js index d100040..4124f72 100644 --- a/errors/exercise3.js +++ b/errors/exercise3.js @@ -1,2 +1,2 @@ let ward = "hello"; -word.substring(1); +ward.substring(1); diff --git a/errors/exercise4.js b/errors/exercise4.js index c59741a..8592f59 100644 --- a/errors/exercise4.js +++ b/errors/exercise4.js @@ -1,5 +1,5 @@ -let numbers = { a: 13, b: 37, c: 42 }; +let numbers = [{ a: 13, b: 37, c: 42 }]; numbers.map(function (num) { - return num * 2; + return num * 2; }); diff --git a/errors/exercise5.js b/errors/exercise5.js index db8a957..06a1b35 100644 --- a/errors/exercise5.js +++ b/errors/exercise5.js @@ -1,2 +1,2 @@ -let name; +let name = "string"; name.substring(1); diff --git a/errors/exercise6.js b/errors/exercise6.js index 8ef8108..f6210b5 100644 --- a/errors/exercise6.js +++ b/errors/exercise6.js @@ -3,8 +3,8 @@ // Item #2 on the list is eggs // Item #3 on the list is milk -let arr ["bread", eggs", "milk"]; +let arr = ["bread", "eggs", "milk"]; -items.forEach(item, index -> { - console.log(`Item #${index + 1} on the list is ${item}`); -}; +arr.forEach((item, index) => { + console.log(`Item #${index + 1} on the list is ${item}`); +}); From 3082a5f72ba2292d02be13428a821df1bb691632 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Mon, 19 Sep 2022 21:35:49 +0200 Subject: [PATCH 02/14] Update exercise7.js incomplete, struggling with this exercise --- errors/exercise7.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/errors/exercise7.js b/errors/exercise7.js index 40633fd..5e021b5 100644 --- a/errors/exercise7.js +++ b/errors/exercise7.js @@ -6,27 +6,27 @@ // ] function getTemperatureReport(cities) { - let report = []; + let report = []; - for(let i = 0; i < cities.length(); i++) { - let temperature = temperatureService(city[i]); - report.push(`The temperature in ${city[i]} is ${temperature} degrees`); - } - return report; + for (let i = 0; i < cities.length; i++) { + let temperature = Object.values(temperatureService(cities[i])); + report.push(`The temperature in ${cities[i]} is ${temperature[i]} degrees`); + } + return report; } function temperatureService() { - let temparatureMap = { - 'London': 10, - 'Paris': 12, - 'Barcelona': 17, - 'Dubai' 27, - 'Mumbai': 29, - 'São Paulo': 23 - 'Lagos': 33 - + let temperatureMap = { + London: 10, + Paris: 12, + Barcelona: 17, + Dubai: 27, + Mumbai: 29, + "São Paulo": 23, + Lagos: 33, + }; - return temparatureMap[city]; + return temperatureMap; } let report = getTemperatureReport(["London", "Paris", "São Paulo"]); From 870a970543d17101e60ac9d662c2fd8de475c2cb Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Tue, 20 Sep 2022 18:50:34 +0200 Subject: [PATCH 03/14] Update exercise7.js --- errors/exercise7.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/errors/exercise7.js b/errors/exercise7.js index 5e021b5..5c4388b 100644 --- a/errors/exercise7.js +++ b/errors/exercise7.js @@ -9,14 +9,14 @@ function getTemperatureReport(cities) { let report = []; for (let i = 0; i < cities.length; i++) { - let temperature = Object.values(temperatureService(cities[i])); - report.push(`The temperature in ${cities[i]} is ${temperature[i]} degrees`); + let temperature = temperatureService(cities[i]); + report.push(`The temperature in ${cities[i]} is ${temperature} degrees`); } return report; } -function temperatureService() { - let temperatureMap = { +function temperatureService(city) { + let temparatureMap = { London: 10, Paris: 12, Barcelona: 17, @@ -25,8 +25,7 @@ function temperatureService() { "São Paulo": 23, Lagos: 33, }; - - return temperatureMap; + return temparatureMap[city]; } let report = getTemperatureReport(["London", "Paris", "São Paulo"]); From 807a06f7f6bacff343210026032f430ad6aaec9f Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Tue, 20 Sep 2022 19:46:26 +0200 Subject: [PATCH 04/14] complete demo folder --- debugging/demo/demo2/index.html | 3 +- debugging/demo/demo2/script.js | 89 +++++++++++++++++---------------- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/debugging/demo/demo2/index.html b/debugging/demo/demo2/index.html index 8cc1a42..2207d59 100644 --- a/debugging/demo/demo2/index.html +++ b/debugging/demo/demo2/index.html @@ -1,6 +1,5 @@ - Javascript Demo Exercise 2
+ + diff --git a/debugging/demo/demo2/script.js b/debugging/demo/demo2/script.js index 1c7bec9..4321eb9 100644 --- a/debugging/demo/demo2/script.js +++ b/debugging/demo/demo2/script.js @@ -1,43 +1,48 @@ -document.addEventListener("DOMContentLoaded", ( ) => { - var data = [ - { - text: 'Overshadowing #UNGA is the big question: Will Obama and Rouhani meet?', - href: 'https://twitter.com/cnnbrk/status/382528782738800641' - }, - { - text: "Marine's family hopes visiting Iranian president will help free their son", - href: 'https://twitter.com/cnnbrk/status/382519683053649920' - }, - { - text: 'Obama addresses United Nations.', - href: 'https://twitter.com/cnnbrk/status/382507500903202817' - }, - { - text: '', - href: 'https://twitter.com/CNNMoney/status/382497891723804672' - }, - { - text: "If you're seeing this as a button, congratulations!", - href: 'http://twitter.com' - } - ]; - for (var i = 0; i { + var data = [ + { + text: "Overshadowing #UNGA is the big question: Will Obama and Rouhani meet?", + href: "https://twitter.com/cnnbrk/status/382528782738800641", + }, + { + text: "Marine's family hopes visiting Iranian president will help free their son", + href: "https://twitter.com/cnnbrk/status/382519683053649920", + }, + { + text: "Obama addresses United Nations.", + href: "https://twitter.com/cnnbrk/status/382507500903202817", + }, + { + text: "", + href: "https://twitter.com/CNNMoney/status/382497891723804672", + }, + { + text: "If you're seeing this as a button, congratulations!", + href: "http://twitter.com", + }, + ]; - buttons.forEach(el => el.addEventListener('click', evt => { - const ctrl = evt.target; - if (!ctrl.getAttribute('data-href')) { - document.location = ctrl.getAttribute('data-href'); - }})) - }) + for (var i = 0; i < data.length; i++) { + if (data[i].text) { + const pElement = document.createElement("p"); + const button = document.createElement("button"); + button.type = "button"; + button.classList.add("btn", "btn-default"); + button.setAttribute("data-href", data[i].href); + button.innerText = data[i].text; + pElement.appendChild(button); + document.querySelector("#news").appendChild(pElement); + } + } + const buttons = document.querySelectorAll("button"); + + buttons.forEach((el) => + el.addEventListener("click", (evt) => { + const ctrl = evt.target; + console.log(ctrl); + if (ctrl.getAttribute("data-href")) { + document.location = ctrl.getAttribute("data-href"); + } + }) + ); +}); From a3d94b871b031f6f7be4f64258b680fa39425abd Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Tue, 20 Sep 2022 19:54:19 +0200 Subject: [PATCH 05/14] Update exercise1.js --- debugging/exercises/exercise1/exercise1.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/debugging/exercises/exercise1/exercise1.js b/debugging/exercises/exercise1/exercise1.js index 9878e8c..5571b7b 100644 --- a/debugging/exercises/exercise1/exercise1.js +++ b/debugging/exercises/exercise1/exercise1.js @@ -8,29 +8,27 @@ const countDown = () => { console.log(secondsTolaunch--); switch (secondsTolaunch) { case 7: - console.log('Close Davy Jones' Locker..'); + console.log("Close Davy Jones" + "Locker.."); break; case 3: - console.log('Ignition...'); + console.log("Ignition..."); break; case 0: - console.log('Liftoff!'); + console.log("Liftoff!"); clearInterval(interval); break; default: break; } - }; - if (fuelLevel >= 20000) { - console.log(('Fuel level cleared.'); - launchReady = true; + console.log("Fuel level cleared."); + launchReady = true; } else { - console.log('WARNING: Insufficient fuel!'); - launchReady = false; + console.log("WARNING: Insufficient fuel!"); + launchReady = false; } -if (launchReady){ - interval = setInterval(countDown, 1000) +if (launchReady) { + interval = setInterval(countDown, 1000); } From fbaa1c23979ec48a6d1dd86612e9d4883d0a3023 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Tue, 20 Sep 2022 21:45:44 +0200 Subject: [PATCH 06/14] debugging exercise partially completed --- debugging/exercises/exercise2/index.html | 2 +- debugging/exercises/exercise2/main.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/debugging/exercises/exercise2/index.html b/debugging/exercises/exercise2/index.html index 3ab2800..4255bdd 100644 --- a/debugging/exercises/exercise2/index.html +++ b/debugging/exercises/exercise2/index.html @@ -77,6 +77,6 @@

Odin's Library

- + diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index dc6b8ee..7980664 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -19,7 +19,7 @@ const book2 = { read: "No", }; -myLibrary.push(book1; +myLibrary.push(book1); myLibrary.push(book2); render(); @@ -28,15 +28,15 @@ addButtons.forEach((button) => { button.addEventListener("click", () => { formContainer.style.display = "block"; }); -}; +}); function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); deleteButtons.forEach((button) => { - if (button.getAttribute("data-book") == bookNumber) { + if (button.getAttribute("data-book") === bookNumber) { //Only add eventListeners to new books - button.addEventListener("clicksss", () => { + button.addEventListener("click", () => { deleteBook(button.getAttribute("data-book")); }); } @@ -47,7 +47,7 @@ function addReadButtons() { let readButtons = document.querySelectorAll(".change-read"); readButtons.forEach((button) => { - if (button.getAttribute("data-book") == bookNumber) { + if (button.getAttribute("data-book") === bookNumber) { button.addEventListener("click", () => { changeReadStatus(button.getAttribute("data-book"), button); }); @@ -58,6 +58,7 @@ function addReadButtons() { function deleteBook(number) { let toDelete = document.querySelector(`tr[data-book="${number}"]`); toDelete.remove(); + console.log(toDelete); } function changeReadStatus(number, button) { @@ -93,7 +94,7 @@ function render() { let titleCell = document.createElement("td"); titleCell.append(myLibrary[i].title); - row.append(titleCella); + row.append(titleCell); let authorCell = document.createElement("td"); authorCell.append(myLibrary[i].author); @@ -120,7 +121,7 @@ function render() { row.append(readCell); let deleteCell = document.createElement("td"); - let deleteB = document.createElement("button"); + let deleteButton = document.createElement("button"); let icon = document.createElement("ion-icon"); icon.setAttribute("name", "trash-outline"); deleteButton.classList.add("delete"); @@ -133,7 +134,7 @@ function render() { tableBody.insertBefore(row, tableBody.firstChild); - addDeletedButtons(); + addDeleteButtons(); addReadButtons(); bookNumber++; @@ -149,7 +150,7 @@ document.getElementById("submit").addEventListener("click", (e) => { for (let element of form.elements) { if (element.id === "read") { - element.checked ? bookArgs.push("No") : bookArgs.push("Yes"); + element.checked ? bookArgs.push("Yes") : bookArgs.push("No"); element.checked = false; } else { bookArgs.push(element.value); From 29923072dbe01965d9c25ef9c51e7a8690edd505 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:01:16 +0200 Subject: [PATCH 07/14] Update main.js --- debugging/exercises/exercise2/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index 7980664..592e704 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -29,7 +29,7 @@ addButtons.forEach((button) => { formContainer.style.display = "block"; }); }); - +debugger; function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); From a04401bc1e830bdb90d3fc7feb74753398edb553 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:02:23 +0200 Subject: [PATCH 08/14] Update main.js --- debugging/exercises/exercise2/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index 592e704..7980664 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -29,7 +29,7 @@ addButtons.forEach((button) => { formContainer.style.display = "block"; }); }); -debugger; + function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); From 46a597c136e57f70511912af020c5805b5a5218b Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:17:00 +0200 Subject: [PATCH 09/14] Update main.js --- debugging/exercises/exercise2/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index 7980664..ed06bd1 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -1,7 +1,7 @@ const addButtons = document.querySelectorAll(".add-button"); const formContainer = document.getElementById("form-container"); const tableBody = document.getElementById("table-body"); -const submitted = document.getElementById("submitted"); +const submitted = document.getElementById("submit"); let bookNumber = 0; let myLibrary = []; From 4cab909ab8f723e2c8b8a90e86a95d14728a5192 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:17:12 +0200 Subject: [PATCH 10/14] Revert "debugging exercise partially completed" This reverts commit fbaa1c23979ec48a6d1dd86612e9d4883d0a3023. --- debugging/exercises/exercise2/index.html | 2 +- debugging/exercises/exercise2/main.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/debugging/exercises/exercise2/index.html b/debugging/exercises/exercise2/index.html index 4255bdd..3ab2800 100644 --- a/debugging/exercises/exercise2/index.html +++ b/debugging/exercises/exercise2/index.html @@ -77,6 +77,6 @@

Odin's Library

- + diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index ed06bd1..737db1a 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -19,7 +19,7 @@ const book2 = { read: "No", }; -myLibrary.push(book1); +myLibrary.push(book1; myLibrary.push(book2); render(); @@ -28,15 +28,15 @@ addButtons.forEach((button) => { button.addEventListener("click", () => { formContainer.style.display = "block"; }); -}); +}; function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); deleteButtons.forEach((button) => { - if (button.getAttribute("data-book") === bookNumber) { + if (button.getAttribute("data-book") == bookNumber) { //Only add eventListeners to new books - button.addEventListener("click", () => { + button.addEventListener("clicksss", () => { deleteBook(button.getAttribute("data-book")); }); } @@ -47,7 +47,7 @@ function addReadButtons() { let readButtons = document.querySelectorAll(".change-read"); readButtons.forEach((button) => { - if (button.getAttribute("data-book") === bookNumber) { + if (button.getAttribute("data-book") == bookNumber) { button.addEventListener("click", () => { changeReadStatus(button.getAttribute("data-book"), button); }); @@ -58,7 +58,6 @@ function addReadButtons() { function deleteBook(number) { let toDelete = document.querySelector(`tr[data-book="${number}"]`); toDelete.remove(); - console.log(toDelete); } function changeReadStatus(number, button) { @@ -94,7 +93,7 @@ function render() { let titleCell = document.createElement("td"); titleCell.append(myLibrary[i].title); - row.append(titleCell); + row.append(titleCella); let authorCell = document.createElement("td"); authorCell.append(myLibrary[i].author); @@ -121,7 +120,7 @@ function render() { row.append(readCell); let deleteCell = document.createElement("td"); - let deleteButton = document.createElement("button"); + let deleteB = document.createElement("button"); let icon = document.createElement("ion-icon"); icon.setAttribute("name", "trash-outline"); deleteButton.classList.add("delete"); @@ -134,7 +133,7 @@ function render() { tableBody.insertBefore(row, tableBody.firstChild); - addDeleteButtons(); + addDeletedButtons(); addReadButtons(); bookNumber++; @@ -150,7 +149,7 @@ document.getElementById("submit").addEventListener("click", (e) => { for (let element of form.elements) { if (element.id === "read") { - element.checked ? bookArgs.push("Yes") : bookArgs.push("No"); + element.checked ? bookArgs.push("No") : bookArgs.push("Yes"); element.checked = false; } else { bookArgs.push(element.value); From 63f8804a02b89cd8789d1804db3ba316026deecd Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:25:07 +0200 Subject: [PATCH 11/14] complete exercise Finally!!!! --- debugging/exercises/exercise2/index.html | 2 +- debugging/exercises/exercise2/main.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/debugging/exercises/exercise2/index.html b/debugging/exercises/exercise2/index.html index 3ab2800..4255bdd 100644 --- a/debugging/exercises/exercise2/index.html +++ b/debugging/exercises/exercise2/index.html @@ -77,6 +77,6 @@

Odin's Library

- + diff --git a/debugging/exercises/exercise2/main.js b/debugging/exercises/exercise2/main.js index 737db1a..f901113 100644 --- a/debugging/exercises/exercise2/main.js +++ b/debugging/exercises/exercise2/main.js @@ -1,7 +1,7 @@ const addButtons = document.querySelectorAll(".add-button"); const formContainer = document.getElementById("form-container"); const tableBody = document.getElementById("table-body"); -const submitted = document.getElementById("submit"); +const submitted = document.getElementById("submitted"); let bookNumber = 0; let myLibrary = []; @@ -19,7 +19,7 @@ const book2 = { read: "No", }; -myLibrary.push(book1; +myLibrary.push(book1); myLibrary.push(book2); render(); @@ -28,7 +28,7 @@ addButtons.forEach((button) => { button.addEventListener("click", () => { formContainer.style.display = "block"; }); -}; +}); function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); @@ -36,7 +36,7 @@ function addDeleteButtons() { deleteButtons.forEach((button) => { if (button.getAttribute("data-book") == bookNumber) { //Only add eventListeners to new books - button.addEventListener("clicksss", () => { + button.addEventListener("click", () => { deleteBook(button.getAttribute("data-book")); }); } @@ -93,7 +93,7 @@ function render() { let titleCell = document.createElement("td"); titleCell.append(myLibrary[i].title); - row.append(titleCella); + row.append(titleCell); let authorCell = document.createElement("td"); authorCell.append(myLibrary[i].author); @@ -120,7 +120,7 @@ function render() { row.append(readCell); let deleteCell = document.createElement("td"); - let deleteB = document.createElement("button"); + let deleteButton = document.createElement("button"); let icon = document.createElement("ion-icon"); icon.setAttribute("name", "trash-outline"); deleteButton.classList.add("delete"); @@ -133,7 +133,7 @@ function render() { tableBody.insertBefore(row, tableBody.firstChild); - addDeletedButtons(); + addDeleteButtons(); addReadButtons(); bookNumber++; @@ -149,7 +149,7 @@ document.getElementById("submit").addEventListener("click", (e) => { for (let element of form.elements) { if (element.id === "read") { - element.checked ? bookArgs.push("No") : bookArgs.push("Yes"); + element.checked ? bookArgs.push("Yes") : bookArgs.push("No"); element.checked = false; } else { bookArgs.push(element.value); @@ -160,6 +160,6 @@ document.getElementById("submit").addEventListener("click", (e) => { } formContainer.style.display = "none"; - addBookToLibrary(bookArgs[1], bookArgs[0], bookArgs[2], bookArgs[3]); + addBookToLibrary(bookArgs[0], bookArgs[1], bookArgs[2], bookArgs[3]); render(); }); From 027dbb74513698b249e84fe7aae404bc0d5fb24c Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:38:32 +0200 Subject: [PATCH 12/14] Update exercise1.js --- debugging/exercises/exercise1/exercise1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/exercises/exercise1/exercise1.js b/debugging/exercises/exercise1/exercise1.js index 5571b7b..1f4b86e 100644 --- a/debugging/exercises/exercise1/exercise1.js +++ b/debugging/exercises/exercise1/exercise1.js @@ -5,7 +5,7 @@ let secondsTolaunch = 10; let interval; const countDown = () => { - console.log(secondsTolaunch--); + console.log(secondsTolaunch); switch (secondsTolaunch) { case 7: console.log("Close Davy Jones" + "Locker.."); From 91d497bce7083e40cf7fad34cb85f5a83a715a26 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:38:37 +0200 Subject: [PATCH 13/14] Revert "Update exercise1.js" This reverts commit a3d94b871b031f6f7be4f64258b680fa39425abd. --- debugging/exercises/exercise1/exercise1.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/debugging/exercises/exercise1/exercise1.js b/debugging/exercises/exercise1/exercise1.js index 1f4b86e..8a16bc1 100644 --- a/debugging/exercises/exercise1/exercise1.js +++ b/debugging/exercises/exercise1/exercise1.js @@ -8,27 +8,29 @@ const countDown = () => { console.log(secondsTolaunch); switch (secondsTolaunch) { case 7: - console.log("Close Davy Jones" + "Locker.."); + console.log('Close Davy Jones' Locker..'); break; case 3: - console.log("Ignition..."); + console.log('Ignition...'); break; case 0: - console.log("Liftoff!"); + console.log('Liftoff!'); clearInterval(interval); break; default: break; } + }; + if (fuelLevel >= 20000) { - console.log("Fuel level cleared."); - launchReady = true; + console.log(('Fuel level cleared.'); + launchReady = true; } else { - console.log("WARNING: Insufficient fuel!"); - launchReady = false; + console.log('WARNING: Insufficient fuel!'); + launchReady = false; } -if (launchReady) { - interval = setInterval(countDown, 1000); +if (launchReady){ + interval = setInterval(countDown, 1000) } From 0325216ce3506202bda9a78665d26b8f69720d94 Mon Sep 17 00:00:00 2001 From: Riyaaz Singh <94745207+Riyaazct@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:39:53 +0200 Subject: [PATCH 14/14] Update exercise1.js --- debugging/exercises/exercise1/exercise1.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/debugging/exercises/exercise1/exercise1.js b/debugging/exercises/exercise1/exercise1.js index 8a16bc1..5571b7b 100644 --- a/debugging/exercises/exercise1/exercise1.js +++ b/debugging/exercises/exercise1/exercise1.js @@ -5,32 +5,30 @@ let secondsTolaunch = 10; let interval; const countDown = () => { - console.log(secondsTolaunch); + console.log(secondsTolaunch--); switch (secondsTolaunch) { case 7: - console.log('Close Davy Jones' Locker..'); + console.log("Close Davy Jones" + "Locker.."); break; case 3: - console.log('Ignition...'); + console.log("Ignition..."); break; case 0: - console.log('Liftoff!'); + console.log("Liftoff!"); clearInterval(interval); break; default: break; } - }; - if (fuelLevel >= 20000) { - console.log(('Fuel level cleared.'); - launchReady = true; + console.log("Fuel level cleared."); + launchReady = true; } else { - console.log('WARNING: Insufficient fuel!'); - launchReady = false; + console.log("WARNING: Insufficient fuel!"); + launchReady = false; } -if (launchReady){ - interval = setInterval(countDown, 1000) +if (launchReady) { + interval = setInterval(countDown, 1000); }