From 7d3bb3cbeb076949a35a56cf405b222b43aa03e7 Mon Sep 17 00:00:00 2001 From: dcostaprakash Date: Fri, 27 Mar 2026 16:54:11 +0000 Subject: [PATCH 1/4] GLASGOW | 26-ITP-Jan | Prakash Dcosta | Sprint 1 | Object Destructuring --- Sprint-1/destructuring/exercise-1/exercise.js | 2 +- Sprint-1/destructuring/exercise-2/exercise.js | 19 +++++++++++++++++++ Sprint-1/destructuring/exercise-3/exercise.js | 17 +++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5c..d86bc7bf 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -6,7 +6,7 @@ const personOne = { // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself({ name, age, favouriteFood }) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb..3f992951 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,22 @@ let hogwarts = [ occupation: "Teacher", }, ]; +/* Task 1 */ +function houseGryffindorNames(array) { + array.forEach(({ firstName, lastName, house }) => { + if (house === "Gryffindor") { + console.log(firstName, lastName); + } + }); +} +houseGryffindorNames(hogwarts); + +/* Task 2 */ +function teachersPetNames(array) { + array.forEach(({ firstName, lastName, occupation, pet }) => { + if (occupation === "Teacher" && pet !== null) { + console.log(firstName, lastName); + } + }); +} +teachersPetNames(hogwarts); diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e..d299e5d1 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,20 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; + +function takeOutOrder(order) { + let totalSum = 0; + + console.log("OTY ITEM TOTAL"); + order.forEach(({ quantity, itemName, unitPricePence }) => { + const itemTotal = (quantity * unitPricePence) / 100; + totalSum += itemTotal; + + console.log( + `${quantity} ${itemName.padEnd(18)} ${itemTotal.toFixed(2)}` + ); + }); + + console.log(`\nTotal: ${totalSum.toFixed(2)}`); +} +takeOutOrder(order); From 938a042459ee44cfed3cbca833e0bf94ea1213a5 Mon Sep 17 00:00:00 2001 From: dcostaprakash Date: Mon, 13 Apr 2026 23:13:58 +0100 Subject: [PATCH 2/4] GLASGOW | 26-ITP-Jan | Prakash Dcosta | Sprint 1 | Object Destructuring --- Project-TV-Show | 1 + .../Project-TV-Show-Partner | 1 + debugging/book-library/script.js | 35 ++++++++----------- 3 files changed, 17 insertions(+), 20 deletions(-) create mode 160000 Project-TV-Show create mode 160000 Project-TV-Show-Partner/Project-TV-Show-Partner diff --git a/Project-TV-Show b/Project-TV-Show new file mode 160000 index 00000000..a3e7d574 --- /dev/null +++ b/Project-TV-Show @@ -0,0 +1 @@ +Subproject commit a3e7d574e97a3e51f6269374dfab847bba22bf72 diff --git a/Project-TV-Show-Partner/Project-TV-Show-Partner b/Project-TV-Show-Partner/Project-TV-Show-Partner new file mode 160000 index 00000000..48a60949 --- /dev/null +++ b/Project-TV-Show-Partner/Project-TV-Show-Partner @@ -0,0 +1 @@ +Subproject commit 48a6094952133b449ad144dc441bc2ec724a6e11 diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 75ce6c1d..8a45d9fb 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -16,7 +16,6 @@ function populateStorage() { ); myLibrary.push(book1); myLibrary.push(book2); - render(); } } @@ -29,17 +28,20 @@ const check = document.getElementById("check"); //via Book function and start render function function submit() { if ( - title.value == null || - title.value == "" || - pages.value == null || - pages.value == "" + title.value.trim() === "" || + author.value.trim() === "" || + pages.value.trim() === "" ) { 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(); + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; } } @@ -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 @@ -72,15 +74,9 @@ function render() { //add and wait for action for read/unread button let changeBut = document.createElement("button"); - changeBut.id = i; changeBut.className = "btn btn-success"; wasReadCell.appendChild(changeBut); - let readStatus = ""; - if (myLibrary[i].check == false) { - readStatus = "Yes"; - } else { - readStatus = "No"; - } + let readStatus = myLibrary[i].check ? "Yes" : "No"; changeBut.innerText = readStatus; changeBut.addEventListener("click", function () { @@ -90,11 +86,10 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); - delBut.id = i + 5; - deleteCell.appendChild(delBut); - delBut.className = "btn btn-warning"; - delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + deleteCell.appendChild(delButton); + delButton.className = "btn btn-warning"; + delButton.innerHTML = "Delete"; + delButton.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From b9267382de4d3712f5e555d0252f2b586afbe471 Mon Sep 17 00:00:00 2001 From: dcostaprakash Date: Wed, 15 Apr 2026 14:34:48 +0100 Subject: [PATCH 3/4] GLASGOW | 26-ITP-Jan | Prakash Dcosta | Sprint 2 | Book Library --- Project-TV-Show | 1 - Project-TV-Show-Partner/Project-TV-Show-Partner | 1 - 2 files changed, 2 deletions(-) delete mode 160000 Project-TV-Show delete mode 160000 Project-TV-Show-Partner/Project-TV-Show-Partner diff --git a/Project-TV-Show b/Project-TV-Show deleted file mode 160000 index a3e7d574..00000000 --- a/Project-TV-Show +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a3e7d574e97a3e51f6269374dfab847bba22bf72 diff --git a/Project-TV-Show-Partner/Project-TV-Show-Partner b/Project-TV-Show-Partner/Project-TV-Show-Partner deleted file mode 160000 index 48a60949..00000000 --- a/Project-TV-Show-Partner/Project-TV-Show-Partner +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 48a6094952133b449ad144dc441bc2ec724a6e11 From d0918b128966e9531f7bd3bc10f190888ca91404 Mon Sep 17 00:00:00 2001 From: dcostaprakash Date: Wed, 15 Apr 2026 14:46:37 +0100 Subject: [PATCH 4/4] GLASGOW | 26-ITP-Jan | Prakash Dcosta | Sprint 2 | Book Library --- Sprint-1/destructuring/exercise-1/exercise.js | 2 +- Sprint-1/destructuring/exercise-2/exercise.js | 19 ------------------- Sprint-1/destructuring/exercise-3/exercise.js | 17 ----------------- 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index d86bc7bf..1ff2ac5c 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -6,7 +6,7 @@ const personOne = { // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself({ name, age, favouriteFood }) { +function introduceYourself(___________________________) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index 3f992951..e11b75eb 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,22 +70,3 @@ let hogwarts = [ occupation: "Teacher", }, ]; -/* Task 1 */ -function houseGryffindorNames(array) { - array.forEach(({ firstName, lastName, house }) => { - if (house === "Gryffindor") { - console.log(firstName, lastName); - } - }); -} -houseGryffindorNames(hogwarts); - -/* Task 2 */ -function teachersPetNames(array) { - array.forEach(({ firstName, lastName, occupation, pet }) => { - if (occupation === "Teacher" && pet !== null) { - console.log(firstName, lastName); - } - }); -} -teachersPetNames(hogwarts); diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index d299e5d1..b3a36f4e 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,20 +6,3 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; - -function takeOutOrder(order) { - let totalSum = 0; - - console.log("OTY ITEM TOTAL"); - order.forEach(({ quantity, itemName, unitPricePence }) => { - const itemTotal = (quantity * unitPricePence) / 100; - totalSum += itemTotal; - - console.log( - `${quantity} ${itemName.padEnd(18)} ${itemTotal.toFixed(2)}` - ); - }); - - console.log(`\nTotal: ${totalSum.toFixed(2)}`); -} -takeOutOrder(order);