From cd295c5d16ac1e482824ec859b14e89f9484dde7 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Thu, 22 Dec 2016 10:44:46 +0000 Subject: [PATCH 01/35] adds sounds when keys are pressed --- 01 - JavaScript Drum Kit/index-START.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..9b5d08b9e1 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,11 @@ From bda721397cd91dea420b54c3a855255ec2b42abf Mon Sep 17 00:00:00 2001 From: George Eaton Date: Thu, 22 Dec 2016 11:18:11 +0000 Subject: [PATCH 02/35] finished drum kit --- 01 - JavaScript Drum Kit/index-START.html | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 9b5d08b9e1..d987477ad2 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -57,13 +57,27 @@ - + key.classList.add('playing'); + } + + var keys = document.querySelectorAll('.key') + keys.forEach(key => key.addEventListener('transitionend', removeTransition)) + + document.addEventListener('keydown', playSound) + From cd91ec58b7b0f3da0e9d1610d1cb68518dd3f34a Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 12:10:56 +0000 Subject: [PATCH 03/35] redoing without using guide --- 01 - JavaScript Drum Kit/index-START.html | 25 ++++++----------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index d987477ad2..5d437a9d2d 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,25 +58,12 @@ From bd83e7ef616ef8ac89a9941246d1b8ca21e5b8c1 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 12:14:24 +0000 Subject: [PATCH 04/35] resets audio file on keydown --- 01 - JavaScript Drum Kit/index-START.html | 1 + 1 file changed, 1 insertion(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 5d437a9d2d..0ae47619e4 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -62,6 +62,7 @@ var audio = (document.querySelector(`audio[data-key = "${event.keyCode}"`)) if (audio === null) return; + audio.currentTime = 0; audio.play(); }); From 30903d5c3e5628ba893e0ce0d52faa109255d1f3 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 12:18:33 +0000 Subject: [PATCH 05/35] refactors playSound into separate function --- 01 - JavaScript Drum Kit/index-START.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 0ae47619e4..6c3a540053 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,13 +58,16 @@ From 5600f1f6e0ba311a46a0e9745e3e992cc0780dd2 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 12:53:40 +0000 Subject: [PATCH 06/35] adds feedback on keypress --- 01 - JavaScript Drum Kit/index-START.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 6c3a540053..9cdb67c835 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,14 +59,20 @@ From 91cf2bc1fecc18843847fea6a537140dba4ad2f2 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 13:14:00 +0000 Subject: [PATCH 07/35] finished --- 01 - JavaScript Drum Kit/index-START.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 9cdb67c835..cfa0f02f88 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -61,8 +61,17 @@ var addFeedback = function(event) { var key = document.querySelector(`div[data-key = "${event.keyCode}"]`); + if (key === null) + return; key.classList.add('playing'); - } + removeFeedback(event); + }; + var removeFeedback = function(event) { + if (event.propertyName != 'transform') { + return + } + event.target.classList.remove('playing'); + }; var playSound = function(event) { var audio = document.querySelector(`audio[data-key = "${event.keyCode}"]`); if (audio === null) @@ -72,6 +81,9 @@ audio.play(); }; + var keys = document.querySelectorAll('.key') + keys.forEach(key => key.addEventListener('transitionend', removeFeedback)) + window.addEventListener('keydown', playSound) From 9c0af7ae1d7f3cef7f8290b4099c016a3e05c7ce Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 14:16:32 +0000 Subject: [PATCH 08/35] second hand moves round each second --- 02 - JS + CSS Clock/index-START.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..58d947df65 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,28 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; /* rotation will pivot on the right hand side (50% by default, rotates from centre) */ + transform: rotate(90deg); /* clock will rotate so hands are at 12. */ + transition: 0.05s; /* each rotation will take 0.5s to complete */ + transition-timing-function: cubic-bezier(0.18, 1.1, 0, 2.15); /* makes ticking effect*/ + } + From be8cc4753fc1e4ff3f2927f9c8bc96cf81e34993 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 14:18:18 +0000 Subject: [PATCH 09/35] seconds starting position fixed --- 02 - JS + CSS Clock/index-START.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 58d947df65..943ea3f19d 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -79,7 +79,7 @@ var now = new Date(); var seconds = now.getSeconds(); console.log(seconds); - var secondsDegrees = (seconds / 60) * 360 /* gets rotational degree for every second */ + var secondsDegrees = ((seconds / 60) * 360) + 90 /* gets rotational degree for every second */ secondHand.style.transform = `rotate(${secondsDegrees}deg)` } setInterval(setDate, 1000); From 10e1f693595ff7f0c6a4992c9c3edfb209c48b3a Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 23 Dec 2016 14:29:40 +0000 Subject: [PATCH 10/35] working for hours and minutes --- 02 - JS + CSS Clock/index-START.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 943ea3f19d..39dbd1b3e5 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -73,14 +73,25 @@ From 5a91afa3936213036f5a7ca5bb674e08935896a9 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:04:29 +0000 Subject: [PATCH 16/35] adds sort function --- 04 - Array Cardio Day 1/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index fc37ae28e6..72739a7b5d 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -41,6 +41,10 @@ // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + var sortedByAge = inventors.sort(function(inventor1, inventor2) { + return inventor1.year - inventor2.year; + }) + console.table(sortedByAge); // Array.prototype.reduce() // 4. How many years did all the inventors live? From 980e7329ca74f23e0028e7b1db88d22e35aa2179 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:05:51 +0000 Subject: [PATCH 17/35] refactors sort function to use arrow function --- 04 - Array Cardio Day 1/index-START.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 72739a7b5d..cd3c69a520 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -41,9 +41,7 @@ // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest - var sortedByAge = inventors.sort(function(inventor1, inventor2) { - return inventor1.year - inventor2.year; - }) + var sortedByAge = inventors.sort((inventor1, inventor2) => inventor1.year - inventor2.year); console.table(sortedByAge); // Array.prototype.reduce() From ff42feb0e2a836bbe3084a895fee8fae2dcb1915 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:16:13 +0000 Subject: [PATCH 18/35] adds reduce function --- 04 - Array Cardio Day 1/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index cd3c69a520..e6801c04bb 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -46,6 +46,10 @@ // Array.prototype.reduce() // 4. How many years did all the inventors live? + var summedAges = inventors.reduce(function(total, inventor) { + return total + (inventor.passed - inventor.year); + }, 0); + console.log(summedAges); // 5. Sort the inventors by years lived From 76f2879ce010a092d57c8f51264a22dbd78f6e02 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:19:30 +0000 Subject: [PATCH 19/35] adds function to sort by age --- 04 - Array Cardio Day 1/index-START.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index e6801c04bb..183d7f9615 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -53,6 +53,11 @@ // 5. Sort the inventors by years lived + var sortedByYears = inventors.sort(function(inventor1, inventor2) { + return (inventor1.passed - inventor1.year) - (inventor2.passed - inventor2.year) + }); + console.table(sortedByYears); + // 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 9e240c8abecc23905c056357a52a07bba4f76f94 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:20:18 +0000 Subject: [PATCH 20/35] refactors sortByAge to use arrow function --- 04 - Array Cardio Day 1/index-START.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 183d7f9615..ba5cfa6b45 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -53,9 +53,7 @@ // 5. Sort the inventors by years lived - var sortedByYears = inventors.sort(function(inventor1, inventor2) { - return (inventor1.passed - inventor1.year) - (inventor2.passed - inventor2.year) - }); + var sortedByYears = inventors.sort((inventor1, inventor2) => (inventor1.passed - inventor1.year) - (inventor2.passed - inventor2.year)); console.table(sortedByYears); // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name From 0c67d69a1b896f80bf64551727464bd6b51c4c06 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:28:42 +0000 Subject: [PATCH 21/35] sorts by last name --- 04 - Array Cardio Day 1/index-START.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index ba5cfa6b45..5d52a7df37 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -62,6 +62,10 @@ // 7. sort Exercise // Sort the people alphabetically by last name + var sortedByLastName = inventors.sort(function(inventor1, inventor2) { + return inventor1.last[0] > inventor2.last[0] ? 1 : -1 + }); + console.table(sortedByLastName); // 8. Reduce Exercise // Sum up the instances of each of these From 51800195a0d89b2eecc2d2f5a885ea258aca1aaa Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:29:52 +0000 Subject: [PATCH 22/35] refactors sortByLastName to use arrow function --- 04 - Array Cardio Day 1/index-START.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 5d52a7df37..205750056a 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -62,9 +62,7 @@ // 7. sort Exercise // Sort the people alphabetically by last name - var sortedByLastName = inventors.sort(function(inventor1, inventor2) { - return inventor1.last[0] > inventor2.last[0] ? 1 : -1 - }); + var sortedByLastName = inventors.sort((inventor1, inventor2) => (inventor1.last[0] > inventor2.last[0]) ? 1 : -1) console.table(sortedByLastName); // 8. Reduce Exercise From 7bbebb8c30ac5dedd93121da8e7e523a6e603938 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:40:21 +0000 Subject: [PATCH 23/35] filterLastNames returns an array of only last names --- 04 - Array Cardio Day 1/index-START.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 205750056a..96535cd48f 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -62,8 +62,14 @@ // 7. sort Exercise // Sort the people alphabetically by last name - var sortedByLastName = inventors.sort((inventor1, inventor2) => (inventor1.last[0] > inventor2.last[0]) ? 1 : -1) - console.table(sortedByLastName); + // var sortedByLastName = people.sort(function(person1, person2) { + // console.log(person1.split(", ")[1][0]); + // }) + + var filterLastNames = people.map(function(person) { + return person.split(", ")[0]; + }); + console.log(filterLastNames); // 8. Reduce Exercise // Sum up the instances of each of these From a9ccb7c255464cb982835eab8b4504c16978cedb Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:46:37 +0000 Subject: [PATCH 24/35] sortByLastName now sorts people array --- 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 96535cd48f..cbbde4bf86 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -62,14 +62,15 @@ // 7. sort Exercise // Sort the people alphabetically by last name - // var sortedByLastName = people.sort(function(person1, person2) { - // console.log(person1.split(", ")[1][0]); - // }) var filterLastNames = people.map(function(person) { return person.split(", ")[0]; }); - console.log(filterLastNames); + + var sortedByLastName = filterLastNames.sort(function(person1, person2) { + return person1 > person2 ? 1 : -1 + }); + console.log(sortedByLastName); // 8. Reduce Exercise // Sum up the instances of each of these From 8c3d603a9a2a29faa3910355e8a93fdbe3c3f1b4 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:47:54 +0000 Subject: [PATCH 25/35] refactors sortByLastName to use arrow function --- 04 - Array Cardio Day 1/index-START.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index cbbde4bf86..ae478a468f 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -63,13 +63,9 @@ // 7. sort Exercise // Sort the people alphabetically by last name - var filterLastNames = people.map(function(person) { - return person.split(", ")[0]; - }); + var filterLastNames = people.map(person => person.split(", ")[0]); - var sortedByLastName = filterLastNames.sort(function(person1, person2) { - return person1 > person2 ? 1 : -1 - }); + var sortedByLastName = filterLastNames.sort((person1, person2) => person1 > person2 ? 1 : -1); console.log(sortedByLastName); // 8. Reduce Exercise From 609082bfcbceacafa50510c0e04fb0871c5b2817 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 12:49:08 +0000 Subject: [PATCH 26/35] refactors summedAges --- 04 - Array Cardio Day 1/index-START.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index ae478a468f..5cddb48daa 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -46,9 +46,7 @@ // Array.prototype.reduce() // 4. How many years did all the inventors live? - var summedAges = inventors.reduce(function(total, inventor) { - return total + (inventor.passed - inventor.year); - }, 0); + var summedAges = inventors.reduce((total, inventor) => total + (inventor.passed - inventor.year), 0); console.log(summedAges); // 5. Sort the inventors by years lived @@ -72,6 +70,7 @@ // Sum up the instances of each of these const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + From 3325f02e16346b302b07232b95d594d727b31be1 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 13:01:57 +0000 Subject: [PATCH 27/35] counts each item in data array --- 04 - Array Cardio Day 1/index-START.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 5cddb48daa..0522a29c6b 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -69,7 +69,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' ]; - + var count = data.reduce(function(object, item) { + if (!object[item]) { + object[item] = 0; + } + object[item]++ + return object + }, {}); + console.log(count); From 8b02e006766818e417c7e467b8987addb970878d Mon Sep 17 00:00:00 2001 From: George Eaton Date: Wed, 28 Dec 2016 13:07:25 +0000 Subject: [PATCH 28/35] sortByLast name now shows full names --- 04 - Array Cardio Day 1/index-START.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 0522a29c6b..8823904562 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -61,9 +61,11 @@ // 7. sort Exercise // Sort the people alphabetically by last name - var filterLastNames = people.map(person => person.split(", ")[0]); - - var sortedByLastName = filterLastNames.sort((person1, person2) => person1 > person2 ? 1 : -1); + var sortedByLastName = people.sort(function(person1, person2) { + var [person1First, person1Second] = person1.split(", "); + var [person2First, person2Second] = person2.split(", "); + return person1First > person2First ? 1 : -1; + }); console.log(sortedByLastName); // 8. Reduce Exercise From 1f32c0bcac97535b371bbc3e2caff659ea6a4cbc Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 12:49:56 +0000 Subject: [PATCH 29/35] uses some function --- 07 - Array Cardio Day 2/index-START.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..a57865a2c1 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,8 +26,15 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + var peopleOver19 = people.some(function(person) { + if ((2016 - person.year) >= 19) { + return true; + } + }); + console.log({peopleOver19}) // Array.prototype.every() // is everyone 19 or older? + // 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 46da7448b5019dcee5ec6c99db39481c1befe999 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 12:51:09 +0000 Subject: [PATCH 30/35] uses new Date function to get current year --- 07 - Array Cardio Day 2/index-START.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index a57865a2c1..0930510e64 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -27,7 +27,8 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? var peopleOver19 = people.some(function(person) { - if ((2016 - person.year) >= 19) { + var currentYear = new Date().getFullYear(); + if ((currentYear - person.year) >= 19) { return true; } }); From f2ef691f3a3a247c14a8822d8eccb9b12dee84d9 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 12:53:36 +0000 Subject: [PATCH 31/35] uses every function --- 07 - Array Cardio Day 2/index-START.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 0930510e64..87a9b5a737 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -34,7 +34,13 @@ }); console.log({peopleOver19}) // Array.prototype.every() // is everyone 19 or older? - + var isEveryoneOver19 = people.every(function(person) { + var currentYear = new Date().getFullYear(); + if (currentYear - person.year >= 19) { + return true; + } + }); + console.log(isEveryoneOver19) // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for From b01e205e02f92b2b8b28030cd8263d52b4e67416 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 12:55:29 +0000 Subject: [PATCH 32/35] refactors every function to use arrow notation --- 07 - Array Cardio Day 2/index-START.html | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 87a9b5a737..08735c5b6f 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -34,13 +34,8 @@ }); console.log({peopleOver19}) // Array.prototype.every() // is everyone 19 or older? - var isEveryoneOver19 = people.every(function(person) { - var currentYear = new Date().getFullYear(); - if (currentYear - person.year >= 19) { - return true; - } - }); - console.log(isEveryoneOver19) + var isEveryoneOver19 = people.every(person => new Date().getFullYear() - person.year >= 19); + console.log({isEveryoneOver19}); // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for From 73f1e7309f9a0978d8d4d99eaa7931f875fefd00 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 12:58:39 +0000 Subject: [PATCH 33/35] adds found function --- 07 - Array Cardio Day 2/index-START.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 08735c5b6f..f3b868955a 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -41,6 +41,9 @@ // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + var found = comments.find(comment => comment.id === 823423); + console.log(found); + // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 From 857ac8c486c7ae032acb88baba36425de4b42938 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 13:04:04 +0000 Subject: [PATCH 34/35] uses findIndex function --- 07 - Array Cardio Day 2/index-START.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index f3b868955a..3f4895b929 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -48,6 +48,15 @@ // Find the comment with this ID // delete the comment with the ID of 823423 + var index = comments.findIndex(function(comment) { + if (comment.id === 823423) { + return true; + } + }); + + var deleted = comments.splice(index, 1); + console.log(deleted) + From 0b62c40dbb7499de57e9029b9ef381c5227326b3 Mon Sep 17 00:00:00 2001 From: George Eaton Date: Fri, 30 Dec 2016 13:37:41 +0000 Subject: [PATCH 35/35] trying out console tricks --- 09 - Dev Tools Domination/index-START.html | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/09 - Dev Tools Domination/index-START.html b/09 - Dev Tools Domination/index-START.html index 196fffd719..ab5c8d4882 100644 --- a/09 - Dev Tools Domination/index-START.html +++ b/09 - Dev Tools Domination/index-START.html @@ -18,28 +18,53 @@ } // Regular + console.log("Hello") // Interpolated + console.log("Hello, my name is %s.", "George"); + var thing = "string" + console.log(`I am a ${thing}.`); // Styled + console.log("%c This is styled", "font-size: 20px; background: red "); // warning! - + console.warn("This is a warning"); // Error :| + console.error("This is an error!"); // Info - + console.info("This is some info") // Testing + var selected = document.querySelector('p'); + console.assert(selected.classList.contains('ouch'), 'You selected the wrong thing'); // clearing - + console.clear(); // Viewing DOM Elements + console.dir(selected); + console.clear(); // Grouping together + dogs.forEach(function(dog) { + console.groupCollapsed (`${dog.name}`) + console.log(`This is ${dog.name}`) + console.log(`${dog.name} is ${dog.age} years old.`) + console.groupEnd(`${dog.name}`) + }) // counting + console.count("George"); + console.count("George"); // timing + console.time('timing'); + console.log("hello"); + console.log("something happening"); + console.timeEnd('timing'); + + console.table(dogs); +