From c2b8abbdded332e73d2c2f113647298f171be6a1 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:31:12 +0000 Subject: [PATCH 01/11] Complete filter method --- 04 - Array Cardio Day 1/index-START.html | 1 + 1 file changed, 1 insertion(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 0dcfd00f40..0f9701f41c 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -38,6 +38,7 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + console.table(inventors.filter((it) => it.year >= 1500 && it.year < 1600)) // Array.prototype.map() // 2. Give us an array of the inventors first and last names From da42c20be8b0054965dd652a1a0b9de7be9a68e1 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:46:29 +0000 Subject: [PATCH 02/11] Complete map & sort method --- 04 - Array Cardio Day 1/index-START.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 0f9701f41c..94f9208ae1 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -42,9 +42,11 @@ // Array.prototype.map() // 2. Give us an array of the inventors first and last names - + console.table(inventors.map((it) => `${it.first} ${it.last}`)) + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + console.table(inventors.sort((a, b) => a.year > b.year ? 1 : -1)) // Array.prototype.reduce() // 4. How many years did all the inventors live all together? From 46b1e3fa300e02ace40de678c142b1aaf86225b9 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:59:38 +0000 Subject: [PATCH 03/11] Update reduce function --- 04 - Array Cardio Day 1/index-START.html | 1 + 1 file changed, 1 insertion(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 94f9208ae1..6b1e4bace5 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -50,6 +50,7 @@ // Array.prototype.reduce() // 4. How many years did all the inventors live all together? + console.table(inventors.reduce((acc, it) => acc += (it.passed - it.year), 0)) // 5. Sort the inventors by years lived From 54baf7003aa022106f9f41568522e5d74474aa80 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 17:11:47 +0000 Subject: [PATCH 04/11] Complete sort method --- 04 - Array Cardio Day 1/index-START.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 6b1e4bace5..ee3b3f6d26 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -45,15 +45,16 @@ console.table(inventors.map((it) => `${it.first} ${it.last}`)) // Array.prototype.sort() - // 3. Sort the inventors by birthdate, oldest to youngest - console.table(inventors.sort((a, b) => a.year > b.year ? 1 : -1)) + // 3. Sort the inventors by birthdate, oldest to youngest [descending] + console.table(inventors.sort((b, a) => a.year > b.year ? 1 : -1)) // Array.prototype.reduce() // 4. How many years did all the inventors live all together? console.table(inventors.reduce((acc, it) => acc += (it.passed - it.year), 0)) - // 5. Sort the inventors by years lived - + // 5. Sort the inventors by years lived [descending] + console.table(inventors.sort((b, a) => (a.passed - a.year) > (b.passed - b.year) ? 1 : -1)) + // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris From e1efa8f9e6c23a83db7033e220e66d4cabb086f2 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 18:55:26 +0000 Subject: [PATCH 05/11] Update query names list --- 04 - Array Cardio Day 1/index-START.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index ee3b3f6d26..39ab5e5ffc 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -56,8 +56,16 @@ console.table(inventors.sort((b, a) => (a.passed - a.year) > (b.passed - b.year) ? 1 : -1)) // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name - // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris - + // from source: https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + // get class ".mw-category" DOM element + let category = document.querySelector(".mw-category") + // get node with all "a" DOM elements + let linksNode = category.querySelectorAll("a") + // convert node to list & map each element to its text content + let blvdNames = Array.from(linksNode).map(it => it.textContent) + // filter list of boulevard names with those containing "de" in name + let deNames = blvdNames.filter((it) => it.includes("de")) + console.table(deNames) // 7. sort Exercise // Sort the people alphabetically by last name From ddc805cd54194782c76517749895be79550c11d8 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:08:32 +0000 Subject: [PATCH 06/11] Update sort preople last names --- 04 - Array Cardio Day 1/index-START.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 39ab5e5ffc..51ca181579 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -68,7 +68,8 @@ console.table(deNames) // 7. sort Exercise - // Sort the people alphabetically by last name + // Sort the people alphabetically by last name [ascending] + console.table(people.sort((a,b) => a > b ? 1 : -1)) // 8. Reduce Exercise // Sum up the instances of each of these From efb45aff9de12dffb5c204d848c0641fb20dd2b3 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:44:49 +0000 Subject: [PATCH 07/11] Update final reduce exercise --- 04 - Array Cardio Day 1/index-START.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 51ca181579..25b6988144 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -74,6 +74,14 @@ // 8. Reduce Exercise // Sum up the instances of each of these const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + // create empty object & properties for each string & cumulative count + console.table( + data.reduce((obj, it) => { + if (obj[it] == undefined) { obj[it] = 0 } + else { obj[it]++ } + return obj + }, {}) + ) From 874399e60c6e572e19828c9322c61a44578e986e Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:48:52 +0000 Subject: [PATCH 08/11] Update reduce exercise --- 04 - Array Cardio Day 1/index-START.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 25b6988144..c46456b44f 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -77,8 +77,8 @@ // create empty object & properties for each string & cumulative count console.table( data.reduce((obj, it) => { - if (obj[it] == undefined) { obj[it] = 0 } - else { obj[it]++ } + if (!obj[it]) { obj[it] = 0 } + obj[it]++ return obj }, {}) ) From 1bb75c9c06b90115290a0dbae3551d9d20a8be95 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 19:49:53 +0000 Subject: [PATCH 09/11] update --- 04 - Array Cardio Day 1/index-START.html | 1 - 1 file changed, 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index c46456b44f..f37b5e4877 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -82,7 +82,6 @@ return obj }, {}) ) - From 7af96b51f1c81edd2b09c521462cfe5c285307c0 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:25:55 +0000 Subject: [PATCH 10/11] Update some & every function examples --- 07 - Array Cardio Day 2/index-START.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 4ca34c7536..7e5a5c4e1a 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -25,13 +25,18 @@ { text: 'Nice Nice Nice!', id: 542328 } ]; + // return person age + let getAge = (personObj) => (new Date()).getFullYear() - personObj.year // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + console.log(people.some((it) => getAge(it) >= 19)) // true // Array.prototype.every() // is everyone 19 or older? + console.log(people.every((it) => getAge(it) >= 19)) // false // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + // Array.prototype.findIndex() // Find the comment with this ID From d664c485be8b8dd86e0d0777f10cc1d37179e915 Mon Sep 17 00:00:00 2001 From: SVENTRIPIKAL <180786857+SVENTRIPIKAL@users.noreply.github.com> Date: Mon, 22 Sep 2025 20:36:21 +0000 Subject: [PATCH 11/11] Update find methods --- 07 - Array Cardio Day 2/index-START.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 7e5a5c4e1a..67433ff807 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -36,12 +36,14 @@ // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + console.table(comments.find((it) => it.id == 823423)) - // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 - + let index = comments.findIndex((it) => it.id == 823423) + comments.splice(index, 1) + console.table(comments)