From d586b88c026b8a5d04b6d654162f9a014a861a38 Mon Sep 17 00:00:00 2001 From: "RELIAS\\wcoleman" Date: Wed, 18 Oct 2017 17:48:39 -0400 Subject: [PATCH 1/2] working on displaying html from js result --- 07 - Array Cardio Day 2/index-START.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 760e920e03..20cc1223fd 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -34,6 +34,18 @@ // Array.prototype.every() // is everyone 19 or older? + const ageCheck = people.every(person => + ((new Date()).getFullYear()) - person.year >= 19); + + let groupOk = '
Group is OK
'; + let groupNotOk = '
Group is not OK
'; + + verifyGroup = ageCheck ? document.getElementbyId("body").innerHTML = groupOk : document.getElementbyId("body").innerHTML = groupNotOk; + + document.body.appendChild(document.createTextNode(verifyGroup)); + + console.log(ageCheck); + // 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 From 03b0c924c1866b42480f04989c81b95beb053fce Mon Sep 17 00:00:00 2001 From: "RELIAS\\wcoleman" Date: Tue, 31 Oct 2017 11:16:21 -0400 Subject: [PATCH 2/2] added find and findindex --- 07 - Array Cardio Day 2/index-START.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 20cc1223fd..aa41c94a6b 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -40,9 +40,9 @@ let groupOk = '
Group is OK
'; let groupNotOk = '
Group is not OK
'; - verifyGroup = ageCheck ? document.getElementbyId("body").innerHTML = groupOk : document.getElementbyId("body").innerHTML = groupNotOk; + /*verifyGroup = ageCheck ? document.getElementbyId("body").innerHTML = groupOk : document.getElementbyId("body").innerHTML = groupNotOk; - document.body.appendChild(document.createTextNode(verifyGroup)); + document.body.appendChild(document.createTextNode(verifyGroup));*/ console.log(ageCheck); @@ -50,10 +50,21 @@ // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + const comment = comments.find(comment => + comment.id === 823423 + ); + + console.log(comment); + // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => + comment.id === 823423); + + comments.splice(index, 1); +