From fb9ac1ae2dd17e441d52a1327ca6c35bb2ce3369 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:05:36 -0300 Subject: [PATCH 01/15] added first commit for javascript 2 project --- README.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 143243273..2acb0b993 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,54 @@ - # JavaScript - II -With some basic JavaScript principles in hand, we can now expand our skills out even further by exploring callback functions, array methods, and closure. Finish each task in order as the concepts build on one another. +With some basic JavaScript principles in hand, we can now expand our skills out even further by exploring callback functions, array methods, and closure. Finish each task in order as the concepts build on one another. ## Set Up The Project With Git **Follow these steps to set up and work on your project:** -* [ ] Create a forked copy of this project. -* [ ] Add your team lead as collaborator on Github. -* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!). -* [ ] Create a new branch: git checkout -b ``. -* [ ] Implement the project on your newly created `` branch, committing changes regularly. -* [ ] Push commits: git push origin ``. +- [ ] Create a forked copy of this project. +- [ ] Add your team lead as collaborator on Github. +- [ ] Clone your OWN version of the repository (Not Lambda's by mistake!). +- [ ] Create a new branch: git checkout -b ``. +- [ ] Implement the project on your newly created `` branch, committing changes regularly. +- [ ] Push commits: git push origin ``. **Follow these steps for completing your project.** -* [ ] Submit a Pull-Request to merge Branch into master (student's Repo). **Please don't merge your own pull request** -* [ ] Add your team lead as a reviewer on the pull-request -* [ ] Your team lead will count the project as complete by merging the branch back into master. +- [ ] Submit a Pull-Request to merge Branch into master (student's Repo). **Please don't merge your own pull request** +- [ ] Add your team lead as a reviewer on the pull-request +- [ ] Your team lead will count the project as complete by merging the branch back into master. ## Task 1: Higher Order Functions and Callbacks This task focuses on getting practice with higher order functions and callback functions by giving you an array of values and instructions on what to do with that array. -* [ ] Review the contents of the [callbacks.js](assignments/callbacks.js) file. Notice you are given an array at the top of the page. Use that array to aid you with your functions. +- [ ] Review the contents of the [callbacks.js](assignments/callbacks.js) file. Notice you are given an array at the top of the page. Use that array to aid you with your functions. -* [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. +- [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. ## Task 2: Array Methods Use `.forEach()`, `.map()`, `.filter()`, and `.reduce()` to loop over an array with 50 objects in it. The [array-methods.js](assignments/array-methods.js) file contains several challenges built around a fundraising 5K fun run event. -* [ ] Review the contents of the [array-methods.js](assignments/array-methods.js) file. +- [ ] Review the contents of the [array-methods.js](assignments/array-methods.js) file. -* [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. +- [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. -* [ ] Notice the last three problems are up to you to create and solve. This is an awesome opportunity for you to push your critical thinking about array methods, have fun with it. +- [ ] Notice the last three problems are up to you to create and solve. This is an awesome opportunity for you to push your critical thinking about array methods, have fun with it. ## Task 3: Closures -We have learned that closures allow us to access values in scope that have already been invoked (lexical scope). +We have learned that closures allow us to access values in scope that have already been invoked (lexical scope). **Hint: Utilize debugger statements in your code in combination with your developer tools to easily identify closure values.** -* [ ] Review the contents of the [closure.js](assignments/closure.js) file. -* [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. +- [ ] Review the contents of the [closure.js](assignments/closure.js) file. +- [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first. ## Stretch Goals -* [ ] Go back through the stretch problems that you skipped over and complete as many as you can. -* [ ] Look up what an IIFE is in JavaScript and experiment with them \ No newline at end of file +- [ ] Go back through the stretch problems that you skipped over and complete as many as you can. +- [ ] Look up what an IIFE is in JavaScript and experiment with them + +# First commit for javascript II project From f96aa9e4e0578a2953279d9723abc279eadaf0a7 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:10:41 -0300 Subject: [PATCH 02/15] added second commit to make sure repo was installed correctly --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2acb0b993..25f79f02c 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,5 @@ We have learned that closures allow us to access values in scope that have alrea - [ ] Look up what an IIFE is in JavaScript and experiment with them # First commit for javascript II project + +# Second commit to make sure repo installed correctly From f4af0eb39941a8cf100e97d80af912688c40c648 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:25:24 -0300 Subject: [PATCH 03/15] completed array methods challenge 1 --- assignments/array-methods.js | 525 +++++++++++++++++++++++++++++++---- 1 file changed, 465 insertions(+), 60 deletions(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index f3862361e..08c4c5400 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -3,77 +3,482 @@ // Scroll to the bottom of the list to use some advanced array methods to help the event director gather some information from the businesses. const runners = [ - { id: 1, first_name: "Charmain", last_name: "Seiler", email: "cseiler0@wired.com", shirt_size: "2XL", company_name: "Divanoodle", donation: 75 }, - { id: 2, first_name: "Whitaker", last_name: "Ierland", email: "wierland1@angelfire.com", shirt_size: "2XL", company_name: "Wordtune", donation: 148 }, - { id: 3, first_name: "Julieta", last_name: "McCloid", email: "jmccloid2@yahoo.com", shirt_size: "S", company_name: "Riffpedia", donation: 171 }, - { id: 4, first_name: "Martynne", last_name: "Paye", email: "mpaye3@sciencedaily.com", shirt_size: "XL", company_name: "Wordware", donation: 288 }, - { id: 5, first_name: "Gussy", last_name: "Raraty", email: "graraty4@ucoz.ru", shirt_size: "L", company_name: "Oozz", donation: 291 }, - { id: 6, first_name: "Yule", last_name: "Tommasetti", email: "ytommasetti5@state.gov", shirt_size: "S", company_name: "Yodo", donation: 27 }, - { id: 7, first_name: "Kathie", last_name: "Majury", email: "kmajury6@guardian.co.uk", shirt_size: "3XL", company_name: "Zoomcast", donation: 261 }, - { id: 8, first_name: "Tanner", last_name: "Branton", email: "tbranton7@tmall.com", shirt_size: "2XL", company_name: "Realmix", donation: 28 }, - { id: 9, first_name: "Sarina", last_name: "Lasham", email: "slasham8@toplist.cz", shirt_size: "XL", company_name: "Gigashots", donation: 110 }, - { id: 10, first_name: "Bertie", last_name: "Lonergan", email: "blonergan9@issuu.com", shirt_size: "3XL", company_name: "Skinte", donation: 62 }, - { id: 11, first_name: "Trevor", last_name: "Studd", email: "tstudda@networkadvertising.org", shirt_size: "S", company_name: "Cogidoo", donation: 76 }, - { id: 12, first_name: "Malachi", last_name: "Okeshott", email: "mokeshottb@chron.com", shirt_size: "M", company_name: "DabZ", donation: 91 }, - { id: 13, first_name: "Berget", last_name: "Logsdail", email: "blogsdailc@wix.com", shirt_size: "M", company_name: "Mymm", donation: 9 }, - { id: 14, first_name: "Loise", last_name: "Rivlin", email: "lrivlind@behance.net", shirt_size: "2XL", company_name: "Linktype", donation: 204 }, - { id: 15, first_name: "Christan", last_name: "Kendall", email: "ckendalle@example.com", shirt_size: "XS", company_name: "Skinix", donation: 252 }, - { id: 16, first_name: "Kayla", last_name: "Whitwam", email: "kwhitwamf@deliciousdays.com", shirt_size: "2XL", company_name: "Oyope", donation: 147 }, - { id: 17, first_name: "Heddie", last_name: "Heningam", email: "hheningamg@tripadvisor.com", shirt_size: "L", company_name: "Skinix", donation: 172 }, - { id: 18, first_name: "Mace", last_name: "Ballinger", email: "mballingerh@a8.net", shirt_size: "S", company_name: "Nlounge", donation: 266 }, - { id: 19, first_name: "Nola", last_name: "Abberley", email: "nabberleyi@jalbum.net", shirt_size: "XL", company_name: "Photospace", donation: 148 }, - { id: 20, first_name: "Nadine", last_name: "Tresler", email: "ntreslerj@marketwatch.com", shirt_size: "3XL", company_name: "Wikido", donation: 292 }, - { id: 21, first_name: "Ulrikaumeko", last_name: "Vuittet", email: "uvuittetk@gov.uk", shirt_size: "S", company_name: "Skinte", donation: 102 }, - { id: 22, first_name: "Saunder", last_name: "Spennock", email: "sspennockl@icq.com", shirt_size: "3XL", company_name: "Kwimbee", donation: 213 }, - { id: 23, first_name: "Carmel", last_name: "Woffinden", email: "cwoffindenm@wikispaces.com", shirt_size: "S", company_name: "Rooxo", donation: 137 }, - { id: 24, first_name: "Marielle", last_name: "Kimmel", email: "mkimmeln@jimdo.com", shirt_size: "M", company_name: "Livetube", donation: 96 }, - { id: 25, first_name: "Brucie", last_name: "Burris", email: "bburriso@slate.com", shirt_size: "2XL", company_name: "Wordtune", donation: 128 }, - { id: 26, first_name: "Juan", last_name: "Berzon", email: "jberzonp@soup.io", shirt_size: "3XL", company_name: "Einti", donation: 234 }, - { id: 27, first_name: "Sacha", last_name: "Olsen", email: "solsenq@reverbnation.com", shirt_size: "2XL", company_name: "Viva", donation: 190 }, - { id: 28, first_name: "Jamey", last_name: "O'Nolan", email: "jonolanr@samsung.com", shirt_size: "XL", company_name: "Skinix", donation: 31 }, - { id: 29, first_name: "Morrie", last_name: "Rainard", email: "mrainards@yale.edu", shirt_size: "XS", company_name: "Podcat", donation: 52 }, - { id: 30, first_name: "Fidel", last_name: "Roskelly", email: "froskellyt@ibm.com", shirt_size: "XS", company_name: "Avavee", donation: 5 }, - { id: 31, first_name: "Toni", last_name: "MacSweeney", email: "tmacsweeneyu@parallels.com", shirt_size: "M", company_name: "Jaloo", donation: 82 }, - { id: 32, first_name: "Jessey", last_name: "Walhedd", email: "jwalheddv@slashdot.org", shirt_size: "L", company_name: "Trilia", donation: 5 }, - { id: 33, first_name: "Karola", last_name: "Piper", email: "kpiperw@ucsd.edu", shirt_size: "3XL", company_name: "Yombu", donation: 110 }, - { id: 34, first_name: "Marley", last_name: "Mitchenson", email: "mmitchensonx@webeden.co.uk", shirt_size: "M", company_name: "Zoonoodle", donation: 97 }, - { id: 35, first_name: "Marrilee", last_name: "Thrasher", email: "mthrashery@opensource.org", shirt_size: "XL", company_name: "Bluejam", donation: 17 }, - { id: 36, first_name: "Tye", last_name: "Manie", email: "tmaniez@netscape.com", shirt_size: "L", company_name: "Kanoodle", donation: 30 }, - { id: 37, first_name: "Charleen", last_name: "Sheering", email: "csheering10@mit.edu", shirt_size: "3XL", company_name: "Jatri", donation: 262 }, - { id: 38, first_name: "Valma", last_name: "Eynaud", email: "veynaud11@archive.org", shirt_size: "XS", company_name: "Jaxbean", donation: 212 }, - { id: 39, first_name: "Dollie", last_name: "McDarmid", email: "dmcdarmid12@tinyurl.com", shirt_size: "S", company_name: "Kayveo", donation: 74 }, - { id: 40, first_name: "Minna", last_name: "Hymas", email: "mhymas13@cornell.edu", shirt_size: "XS", company_name: "Vimbo", donation: 101 }, - { id: 41, first_name: "Jsandye", last_name: "Frend", email: "jfrend14@ca.gov", shirt_size: "XS", company_name: "Latz", donation: 156 }, - { id: 42, first_name: "Yevette", last_name: "Hacket", email: "yhacket15@wp.com", shirt_size: "XL", company_name: "Lazzy", donation: 291 }, - { id: 43, first_name: "Hank", last_name: "Zebedee", email: "hzebedee16@ezinearticles.com", shirt_size: "L", company_name: "Gigashots", donation: 241 }, - { id: 44, first_name: "Jodie", last_name: "Stawell", email: "jstawell17@yale.edu", shirt_size: "S", company_name: "Jaxspan", donation: 262 }, - { id: 45, first_name: "Falito", last_name: "Karsh", email: "fkarsh18@pcworld.com", shirt_size: "S", company_name: "Mycat", donation: 239 }, - { id: 46, first_name: "Reginauld", last_name: "Purselowe", email: "rpurselowe19@thetimes.co.uk", shirt_size: "L", company_name: "Jabbersphere", donation: 11 }, - { id: 47, first_name: "Vida", last_name: "Tydd", email: "vtydd1a@dropbox.com", shirt_size: "S", company_name: "Quaxo", donation: 55 }, - { id: 48, first_name: "Anderea", last_name: "MacGiolla Pheadair", email: "amacgiollapheadair1b@xing.com", shirt_size: "2XL", company_name: "Kwimbee", donation: 214 }, - { id: 49, first_name: "Bel", last_name: "Alway", email: "balway1c@ow.ly", shirt_size: "S", company_name: "Voolia", donation: 107 }, - { id: 50, first_name: "Shell", last_name: "Baine", email: "sbaine1d@intel.com", shirt_size: "M", company_name: "Gabtype", donation: 171 }, -]; + { + id: 1, + first_name: 'Charmain', + last_name: 'Seiler', + email: 'cseiler0@wired.com', + shirt_size: '2XL', + company_name: 'Divanoodle', + donation: 75 + }, + { + id: 2, + first_name: 'Whitaker', + last_name: 'Ierland', + email: 'wierland1@angelfire.com', + shirt_size: '2XL', + company_name: 'Wordtune', + donation: 148 + }, + { + id: 3, + first_name: 'Julieta', + last_name: 'McCloid', + email: 'jmccloid2@yahoo.com', + shirt_size: 'S', + company_name: 'Riffpedia', + donation: 171 + }, + { + id: 4, + first_name: 'Martynne', + last_name: 'Paye', + email: 'mpaye3@sciencedaily.com', + shirt_size: 'XL', + company_name: 'Wordware', + donation: 288 + }, + { + id: 5, + first_name: 'Gussy', + last_name: 'Raraty', + email: 'graraty4@ucoz.ru', + shirt_size: 'L', + company_name: 'Oozz', + donation: 291 + }, + { + id: 6, + first_name: 'Yule', + last_name: 'Tommasetti', + email: 'ytommasetti5@state.gov', + shirt_size: 'S', + company_name: 'Yodo', + donation: 27 + }, + { + id: 7, + first_name: 'Kathie', + last_name: 'Majury', + email: 'kmajury6@guardian.co.uk', + shirt_size: '3XL', + company_name: 'Zoomcast', + donation: 261 + }, + { + id: 8, + first_name: 'Tanner', + last_name: 'Branton', + email: 'tbranton7@tmall.com', + shirt_size: '2XL', + company_name: 'Realmix', + donation: 28 + }, + { + id: 9, + first_name: 'Sarina', + last_name: 'Lasham', + email: 'slasham8@toplist.cz', + shirt_size: 'XL', + company_name: 'Gigashots', + donation: 110 + }, + { + id: 10, + first_name: 'Bertie', + last_name: 'Lonergan', + email: 'blonergan9@issuu.com', + shirt_size: '3XL', + company_name: 'Skinte', + donation: 62 + }, + { + id: 11, + first_name: 'Trevor', + last_name: 'Studd', + email: 'tstudda@networkadvertising.org', + shirt_size: 'S', + company_name: 'Cogidoo', + donation: 76 + }, + { + id: 12, + first_name: 'Malachi', + last_name: 'Okeshott', + email: 'mokeshottb@chron.com', + shirt_size: 'M', + company_name: 'DabZ', + donation: 91 + }, + { + id: 13, + first_name: 'Berget', + last_name: 'Logsdail', + email: 'blogsdailc@wix.com', + shirt_size: 'M', + company_name: 'Mymm', + donation: 9 + }, + { + id: 14, + first_name: 'Loise', + last_name: 'Rivlin', + email: 'lrivlind@behance.net', + shirt_size: '2XL', + company_name: 'Linktype', + donation: 204 + }, + { + id: 15, + first_name: 'Christan', + last_name: 'Kendall', + email: 'ckendalle@example.com', + shirt_size: 'XS', + company_name: 'Skinix', + donation: 252 + }, + { + id: 16, + first_name: 'Kayla', + last_name: 'Whitwam', + email: 'kwhitwamf@deliciousdays.com', + shirt_size: '2XL', + company_name: 'Oyope', + donation: 147 + }, + { + id: 17, + first_name: 'Heddie', + last_name: 'Heningam', + email: 'hheningamg@tripadvisor.com', + shirt_size: 'L', + company_name: 'Skinix', + donation: 172 + }, + { + id: 18, + first_name: 'Mace', + last_name: 'Ballinger', + email: 'mballingerh@a8.net', + shirt_size: 'S', + company_name: 'Nlounge', + donation: 266 + }, + { + id: 19, + first_name: 'Nola', + last_name: 'Abberley', + email: 'nabberleyi@jalbum.net', + shirt_size: 'XL', + company_name: 'Photospace', + donation: 148 + }, + { + id: 20, + first_name: 'Nadine', + last_name: 'Tresler', + email: 'ntreslerj@marketwatch.com', + shirt_size: '3XL', + company_name: 'Wikido', + donation: 292 + }, + { + id: 21, + first_name: 'Ulrikaumeko', + last_name: 'Vuittet', + email: 'uvuittetk@gov.uk', + shirt_size: 'S', + company_name: 'Skinte', + donation: 102 + }, + { + id: 22, + first_name: 'Saunder', + last_name: 'Spennock', + email: 'sspennockl@icq.com', + shirt_size: '3XL', + company_name: 'Kwimbee', + donation: 213 + }, + { + id: 23, + first_name: 'Carmel', + last_name: 'Woffinden', + email: 'cwoffindenm@wikispaces.com', + shirt_size: 'S', + company_name: 'Rooxo', + donation: 137 + }, + { + id: 24, + first_name: 'Marielle', + last_name: 'Kimmel', + email: 'mkimmeln@jimdo.com', + shirt_size: 'M', + company_name: 'Livetube', + donation: 96 + }, + { + id: 25, + first_name: 'Brucie', + last_name: 'Burris', + email: 'bburriso@slate.com', + shirt_size: '2XL', + company_name: 'Wordtune', + donation: 128 + }, + { + id: 26, + first_name: 'Juan', + last_name: 'Berzon', + email: 'jberzonp@soup.io', + shirt_size: '3XL', + company_name: 'Einti', + donation: 234 + }, + { + id: 27, + first_name: 'Sacha', + last_name: 'Olsen', + email: 'solsenq@reverbnation.com', + shirt_size: '2XL', + company_name: 'Viva', + donation: 190 + }, + { + id: 28, + first_name: 'Jamey', + last_name: "O'Nolan", + email: 'jonolanr@samsung.com', + shirt_size: 'XL', + company_name: 'Skinix', + donation: 31 + }, + { + id: 29, + first_name: 'Morrie', + last_name: 'Rainard', + email: 'mrainards@yale.edu', + shirt_size: 'XS', + company_name: 'Podcat', + donation: 52 + }, + { + id: 30, + first_name: 'Fidel', + last_name: 'Roskelly', + email: 'froskellyt@ibm.com', + shirt_size: 'XS', + company_name: 'Avavee', + donation: 5 + }, + { + id: 31, + first_name: 'Toni', + last_name: 'MacSweeney', + email: 'tmacsweeneyu@parallels.com', + shirt_size: 'M', + company_name: 'Jaloo', + donation: 82 + }, + { + id: 32, + first_name: 'Jessey', + last_name: 'Walhedd', + email: 'jwalheddv@slashdot.org', + shirt_size: 'L', + company_name: 'Trilia', + donation: 5 + }, + { + id: 33, + first_name: 'Karola', + last_name: 'Piper', + email: 'kpiperw@ucsd.edu', + shirt_size: '3XL', + company_name: 'Yombu', + donation: 110 + }, + { + id: 34, + first_name: 'Marley', + last_name: 'Mitchenson', + email: 'mmitchensonx@webeden.co.uk', + shirt_size: 'M', + company_name: 'Zoonoodle', + donation: 97 + }, + { + id: 35, + first_name: 'Marrilee', + last_name: 'Thrasher', + email: 'mthrashery@opensource.org', + shirt_size: 'XL', + company_name: 'Bluejam', + donation: 17 + }, + { + id: 36, + first_name: 'Tye', + last_name: 'Manie', + email: 'tmaniez@netscape.com', + shirt_size: 'L', + company_name: 'Kanoodle', + donation: 30 + }, + { + id: 37, + first_name: 'Charleen', + last_name: 'Sheering', + email: 'csheering10@mit.edu', + shirt_size: '3XL', + company_name: 'Jatri', + donation: 262 + }, + { + id: 38, + first_name: 'Valma', + last_name: 'Eynaud', + email: 'veynaud11@archive.org', + shirt_size: 'XS', + company_name: 'Jaxbean', + donation: 212 + }, + { + id: 39, + first_name: 'Dollie', + last_name: 'McDarmid', + email: 'dmcdarmid12@tinyurl.com', + shirt_size: 'S', + company_name: 'Kayveo', + donation: 74 + }, + { + id: 40, + first_name: 'Minna', + last_name: 'Hymas', + email: 'mhymas13@cornell.edu', + shirt_size: 'XS', + company_name: 'Vimbo', + donation: 101 + }, + { + id: 41, + first_name: 'Jsandye', + last_name: 'Frend', + email: 'jfrend14@ca.gov', + shirt_size: 'XS', + company_name: 'Latz', + donation: 156 + }, + { + id: 42, + first_name: 'Yevette', + last_name: 'Hacket', + email: 'yhacket15@wp.com', + shirt_size: 'XL', + company_name: 'Lazzy', + donation: 291 + }, + { + id: 43, + first_name: 'Hank', + last_name: 'Zebedee', + email: 'hzebedee16@ezinearticles.com', + shirt_size: 'L', + company_name: 'Gigashots', + donation: 241 + }, + { + id: 44, + first_name: 'Jodie', + last_name: 'Stawell', + email: 'jstawell17@yale.edu', + shirt_size: 'S', + company_name: 'Jaxspan', + donation: 262 + }, + { + id: 45, + first_name: 'Falito', + last_name: 'Karsh', + email: 'fkarsh18@pcworld.com', + shirt_size: 'S', + company_name: 'Mycat', + donation: 239 + }, + { + id: 46, + first_name: 'Reginauld', + last_name: 'Purselowe', + email: 'rpurselowe19@thetimes.co.uk', + shirt_size: 'L', + company_name: 'Jabbersphere', + donation: 11 + }, + { + id: 47, + first_name: 'Vida', + last_name: 'Tydd', + email: 'vtydd1a@dropbox.com', + shirt_size: 'S', + company_name: 'Quaxo', + donation: 55 + }, + { + id: 48, + first_name: 'Anderea', + last_name: 'MacGiolla Pheadair', + email: 'amacgiollapheadair1b@xing.com', + shirt_size: '2XL', + company_name: 'Kwimbee', + donation: 214 + }, + { + id: 49, + first_name: 'Bel', + last_name: 'Alway', + email: 'balway1c@ow.ly', + shirt_size: 'S', + company_name: 'Voolia', + donation: 107 + }, + { + id: 50, + first_name: 'Shell', + last_name: 'Baine', + email: 'sbaine1d@intel.com', + shirt_size: 'M', + company_name: 'Gabtype', + donation: 171 + } +] // ==== Challenge 1: Use .forEach() ==== // The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names and populate a new array called `fullNames`. This array will contain just strings. -let fullNames = []; -console.log(fullNames); +let fullNames = [] +// use forEach to loop over the runners array data to get -> ${first_name} and ${last_name} +// push the items we're looking for into fullNames array to output the results -> then console.log(fullNames) +runners.forEach(function(items) { + return fullNames.push(`${items.first_name} ${items.last_name}`) +}) +console.log(fullNames) // ==== Challenge 2: Use .map() ==== // The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings. -let firstNamesAllCaps = []; -console.log(firstNamesAllCaps); +let firstNamesAllCaps = [] +console.log(firstNamesAllCaps) // ==== Challenge 3: Use .filter() ==== // The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects. -let runnersLargeSizeShirt = []; -console.log(runnersLargeSizeShirt); +let runnersLargeSizeShirt = [] +console.log(runnersLargeSizeShirt) // ==== Challenge 4: Use .reduce() ==== // The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable. -let ticketPriceTotal = 0; -console.log(ticketPriceTotal); +let ticketPriceTotal = 0 +console.log(ticketPriceTotal) // ==== Challenge 5: Be Creative ==== // Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above. @@ -82,4 +487,4 @@ console.log(ticketPriceTotal); // Problem 2 -// Problem 3 \ No newline at end of file +// Problem 3 From ec946fbe328c817614b4422b81b7b08c697c7c5c Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:34:34 -0300 Subject: [PATCH 04/15] completed challenge two array methods and made uppercase --- assignments/array-methods.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index 08c4c5400..fd7724d91 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -467,7 +467,8 @@ console.log(fullNames) // ==== Challenge 2: Use .map() ==== // The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings. -let firstNamesAllCaps = [] +//use .map to loop over the runners array to get -> ${first_name}.toUpperCase +let firstNamesAllCaps = runners.map(items => `${items.last_name.toLocaleLowerCase()}`) console.log(firstNamesAllCaps) // ==== Challenge 3: Use .filter() ==== From 2bc17614d668cce53dfaec9c2c3cc0ec36e930e9 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:38:56 -0300 Subject: [PATCH 05/15] completed array methods challenge three --- assignments/array-methods.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index fd7724d91..90473b58c 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -468,12 +468,13 @@ console.log(fullNames) // ==== Challenge 2: Use .map() ==== // The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings. //use .map to loop over the runners array to get -> ${first_name}.toUpperCase -let firstNamesAllCaps = runners.map(items => `${items.last_name.toLocaleLowerCase()}`) +let firstNamesAllCaps = runners.map(items => items.last_name.toLocaleUpperCase()) console.log(firstNamesAllCaps) // ==== Challenge 3: Use .filter() ==== // The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects. -let runnersLargeSizeShirt = [] +//filter runners array for ONLY ${shirt_size === 'L} +let runnersLargeSizeShirt = runners.filter(items => items.shirt_size === 'L') console.log(runnersLargeSizeShirt) // ==== Challenge 4: Use .reduce() ==== From bf94ba7f9e3606aa4de880a48d110d39ef84b939 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 16:46:21 -0300 Subject: [PATCH 06/15] completed array methods challenge four or reduce --- assignments/array-methods.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index 90473b58c..9a7b2aad5 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -479,7 +479,10 @@ console.log(runnersLargeSizeShirt) // ==== Challenge 4: Use .reduce() ==== // The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable. -let ticketPriceTotal = 0 +//use reduce to sum the ${donation} property for a total. +let ticketPriceTotal = runners.reduce((accumulator, items) => { + return accumulator + items.donation +}, 0) console.log(ticketPriceTotal) // ==== Challenge 5: Be Creative ==== From 6f22228175a2f1cb0661685b98fdbc694c435369 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 18:06:16 -0300 Subject: [PATCH 07/15] completed callback challenge one --- assignments/callbacks.js | 49 +++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/assignments/callbacks.js b/assignments/callbacks.js index cb72e70c9..4fa9fcefd 100644 --- a/assignments/callbacks.js +++ b/assignments/callbacks.js @@ -1,6 +1,6 @@ // Create a higher order function and invoke the callback function to test your work. You have been provided an example of a problem and a solution to see how this works with our items array. Study both the problem and the solution to figure out the rest of the problems. -const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum']; +const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'] /* @@ -38,32 +38,39 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum']; console.log(test2); // "this Pencil is worth a million dollars!" */ - function getLength(arr, cb) { - // getLength passes the length of the array into the callback. + // getLength passes the length of the array into the callback. + return cb(arr.length) } +console.log(getLength(items, displayLength)) -function last(arr, cb) { - // last passes the last item of the array into the callback. +//build a function to pass into cb to use the length +function displayLength(name) { + return `The length of array is ${name}` } +displayLength('Todd') -function sumNums(x, y, cb) { - // sumNums adds two numbers (x, y) and passes the result to the callback. -} +// //function last(arr, cb) { +// // last passes the last item of the array into the callback. +// } -function multiplyNums(x, y, cb) { - // multiplyNums multiplies two numbers and passes the result to the callback. -} +// //function sumNums(x, y, cb) { +// // sumNums adds two numbers (x, y) and passes the result to the callback. +// } -function contains(item, list, cb) { - // contains checks if an item is present inside of the given array/list. - // Pass true to the callback if it is, otherwise pass false. -} +// //function multiplyNums(x, y, cb) { +// // multiplyNums multiplies two numbers and passes the result to the callback. +// } -/* STRETCH PROBLEM */ +// //function contains(item, list, cb) { +// // contains checks if an item is present inside of the given array/list. +// // Pass true to the callback if it is, otherwise pass false. +// } -function removeDuplicates(array, cb) { - // removeDuplicates removes all duplicate values from the given array. - // Pass the duplicate free array to the callback function. - // Do not mutate the original array. -} +// /* STRETCH PROBLEM */ + +// //function removeDuplicates(array, cb) { +// // removeDuplicates removes all duplicate values from the given array. +// // Pass the duplicate free array to the callback function. +// // Do not mutate the original array. +// } From 5bca51925c9a2588a2054d618bed2ea8fed7e9f0 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 18:37:22 -0300 Subject: [PATCH 08/15] completed challenge 5 in arary methods --- assignments/array-methods.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index 9a7b2aad5..132b31672 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -489,7 +489,15 @@ console.log(ticketPriceTotal) // Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above. // Problem 1 - +//I'd like to create and export a list of names for an external email list to sent content. +const emailList = runners.map(items => `${items.first_name}, ${items.last_name}, ${items.email}`) +console.log(emailList) // Problem 2 +//I'd like to create a list of companies who donated the most money above a certian limit to prioritize and high value donors +const valueableDonors = runners.filter(items => items.donation >= 200) +console.log(valueableDonors) // Problem 3 +//Create a liste of companies who donated less than 100 to send hand written cards +const writtenCards = runners.filter(items => items.donation <= 100) +console.log(writtenCards) From 753e441eab76d46b74559a984130318066368d19 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 18:55:30 -0300 Subject: [PATCH 09/15] working on closure challenge 1 --- assignments/closure.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/assignments/closure.js b/assignments/closure.js index 4b399c098..7879dfbcc 100644 --- a/assignments/closure.js +++ b/assignments/closure.js @@ -4,19 +4,35 @@ // that manipulates variables defined in the outer scope. // The outer scope can be a parent function, or the top level of the script. +/*Use NHL hockey leagues to call up players*/ +function nhl(name) { + const nhlPlayer = 'Superstar' + console.log(`${name} is a ${nhlPlayer}`) -/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */ + function ahl(player) { + // const fighter = 'Goon' + console.log(`${player} is rough ${nhlPlayer}`) + + function echl(veteran) { + console.log(`${veteran} is in the minor leagues`) + } //this closes the echl + echl('Todd Murphy') + } //this closes the ahl + ahl('Liam Murphy') +} //this closes the nhl +nhl('Sydney Crosby') +/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */ // ==== Challenge 2: Implement a "counter maker" function ==== const counterMaker = () => { - // IMPLEMENTATION OF counterMaker: - // 1- Declare a `count` variable with a value of 0. We will be mutating it, so declare it using `let`! - // 2- Declare a function `counter`. It should increment and return `count`. - // NOTE: This `counter` function, being nested inside `counterMaker`, - // "closes over" the `count` variable. It can "see" it in the parent scope! - // 3- Return the `counter` function. -}; + // IMPLEMENTATION OF counterMaker: + // 1- Declare a `count` variable with a value of 0. We will be mutating it, so declare it using `let`! + // 2- Declare a function `counter`. It should increment and return `count`. + // NOTE: This `counter` function, being nested inside `counterMaker`, + // "closes over" the `count` variable. It can "see" it in the parent scope! + // 3- Return the `counter` function. +} // Example usage: const myCounter = counterMaker(); // myCounter(); // 1 // myCounter(); // 2 @@ -27,7 +43,7 @@ const counterMaker = () => { // ==== Challenge 4: Create a counter function with an object that can increment and decrement ==== const counterFactory = () => { - // Return an object that has two methods called `increment` and `decrement`. - // `increment` should increment a counter variable in closure scope and return it. - // `decrement` should decrement the counter variable and return it. -}; + // Return an object that has two methods called `increment` and `decrement`. + // `increment` should increment a counter variable in closure scope and return it. + // `decrement` should decrement the counter variable and return it. +} From 6e96fd4219795ef2edc9708e9927c047440b524e Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 19:43:09 -0300 Subject: [PATCH 10/15] updated array for touppercase --- assignments/array-methods.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index 132b31672..dcd89ff6e 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -468,8 +468,10 @@ console.log(fullNames) // ==== Challenge 2: Use .map() ==== // The event director needs to have all the runners' first names in uppercase because the director BECAME DRUNK WITH POWER. Populate an array called `firstNamesAllCaps`. This array will contain just strings. //use .map to loop over the runners array to get -> ${first_name}.toUpperCase -let firstNamesAllCaps = runners.map(items => items.last_name.toLocaleUpperCase()) -console.log(firstNamesAllCaps) +let firstNamesUpperCase = runners.map(items => items.first_name.toUpperCase()) +console.log(firstNamesUpperCase) +// let UpperCase = firstNames.toUpperCase() //I tried this but it would't work so i didnt have to add .toUpperCase to he filter array +// console.log(firstNameUpperCase) // ==== Challenge 3: Use .filter() ==== // The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects. From ffd0b98ea76bffa14bdc6c124ab3eece71288417 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 19:48:06 -0300 Subject: [PATCH 11/15] fixed to uppercase but cant get to work in the console log --- assignments/array-methods.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index dcd89ff6e..b5f2fc376 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -470,8 +470,8 @@ console.log(fullNames) //use .map to loop over the runners array to get -> ${first_name}.toUpperCase let firstNamesUpperCase = runners.map(items => items.first_name.toUpperCase()) console.log(firstNamesUpperCase) -// let UpperCase = firstNames.toUpperCase() //I tried this but it would't work so i didnt have to add .toUpperCase to he filter array -// console.log(firstNameUpperCase) +// let upperCase = firstNamesUpperCase //I tried this but it would't work so i didnt have to add .toUpperCase to he filter array +// console.log(upperCase.toUpperCase()) // ==== Challenge 3: Use .filter() ==== // The large shirts won't be available for the event due to an ordering issue. We need a filtered version of the runners array, containing only those runners with large sized shirts so they can choose a different size. This will be an array of objects. From 9d3f1bc9c918dd537f2f5e0cc368b8bbc1eec510 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 19:52:16 -0300 Subject: [PATCH 12/15] completed challenge one in closure --- assignments/closure.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/assignments/closure.js b/assignments/closure.js index 7879dfbcc..3bfcb9490 100644 --- a/assignments/closure.js +++ b/assignments/closure.js @@ -10,11 +10,13 @@ function nhl(name) { console.log(`${name} is a ${nhlPlayer}`) function ahl(player) { - // const fighter = 'Goon' - console.log(`${player} is rough ${nhlPlayer}`) + const fighter = 'Goon' + console.log(`${player} is rough ${nhlPlayer} and ${fighter}`) function echl(veteran) { - console.log(`${veteran} is in the minor leagues`) + console.log( + `${veteran} is in the minor leagues and got in a fight with ${nhlPlayer} ${name}` + ) } //this closes the echl echl('Todd Murphy') } //this closes the ahl From ca6e87100cccb6bd3883ea2486d2e6c4d4af94e7 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 20:24:58 -0300 Subject: [PATCH 13/15] completed callbacks challenge 2 --- assignments/callbacks.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/assignments/callbacks.js b/assignments/callbacks.js index 4fa9fcefd..35db3261a 100644 --- a/assignments/callbacks.js +++ b/assignments/callbacks.js @@ -50,26 +50,40 @@ function displayLength(name) { } displayLength('Todd') -// //function last(arr, cb) { -// // last passes the last item of the array into the callback. -// } +function last(items, cb) { + // last passes the last item of the array into the callback. + return cb(items[items.length - 1]) +} +console.log(last(items, lastItem)) -// //function sumNums(x, y, cb) { -// // sumNums adds two numbers (x, y) and passes the result to the callback. -// } +function lastItem(placeHolder) { + //placehoder is pulling from the cb(...) i dont' understand how cb gets to placeholder + return `The last item in the items array is ${placeHolder}` +} +lastItem() -// //function multiplyNums(x, y, cb) { +function sumNums(x, y, cb) { + // sumNums adds two numbers (x, y) and passes the result to the callback. + return cb(x + y) +} +sumNums(num1, num2, addSum) + +function addSum(newPlaceHolder) { + return ` text... ${newPlaceHolder}` +} +addSum() +// function multiplyNums(x, y, cb) { // // multiplyNums multiplies two numbers and passes the result to the callback. // } -// //function contains(item, list, cb) { +// function contains(item, list, cb) { // // contains checks if an item is present inside of the given array/list. // // Pass true to the callback if it is, otherwise pass false. // } // /* STRETCH PROBLEM */ -// //function removeDuplicates(array, cb) { +// function removeDuplicates(array, cb) { // // removeDuplicates removes all duplicate values from the given array. // // Pass the duplicate free array to the callback function. // // Do not mutate the original array. From 8ceabeb09e90587f9f980d5577373d47cec1acea Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 22:01:13 -0300 Subject: [PATCH 14/15] udpated callbacks --- assignments/array-methods.js | 2 ++ assignments/callbacks.js | 40 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/assignments/array-methods.js b/assignments/array-methods.js index b5f2fc376..903c2a012 100644 --- a/assignments/array-methods.js +++ b/assignments/array-methods.js @@ -483,6 +483,8 @@ console.log(runnersLargeSizeShirt) // The donations need to be tallied up and reported for tax purposes. Add up all the donations and save the total into a ticketPriceTotal variable. //use reduce to sum the ${donation} property for a total. let ticketPriceTotal = runners.reduce((accumulator, items) => { + // console.log(accumulator) + // console.log(items.donation) return accumulator + items.donation }, 0) console.log(ticketPriceTotal) diff --git a/assignments/callbacks.js b/assignments/callbacks.js index 35db3261a..672490d3b 100644 --- a/assignments/callbacks.js +++ b/assignments/callbacks.js @@ -52,34 +52,34 @@ displayLength('Todd') function last(items, cb) { // last passes the last item of the array into the callback. - return cb(items[items.length - 1]) } -console.log(last(items, lastItem)) -function lastItem(placeHolder) { - //placehoder is pulling from the cb(...) i dont' understand how cb gets to placeholder - return `The last item in the items array is ${placeHolder}` +function sumNums(num1, num2, cb) { + // sumNums adds two numbers (x, y) and passes the result to the callback. + return cb(num1, num2) } -lastItem() -function sumNums(x, y, cb) { - // sumNums adds two numbers (x, y) and passes the result to the callback. - return cb(x + y) +const add = (num1, num2) => { + return num1 + num2 +} //We pass 'add' into sumNums as an argument which then gets passed to the 'cb' parameter. + +console.log(sumNums(5, 5, add)) + +function multiplyNums(num1, num2, cb) { + // multiplyNums multiplies two numbers and passes the result to the callback. + return cb(num1, num2) } -sumNums(num1, num2, addSum) -function addSum(newPlaceHolder) { - return ` text... ${newPlaceHolder}` +const multiply = (num1, num2) => { + return num1 * num2 } -addSum() -// function multiplyNums(x, y, cb) { -// // multiplyNums multiplies two numbers and passes the result to the callback. -// } -// function contains(item, list, cb) { -// // contains checks if an item is present inside of the given array/list. -// // Pass true to the callback if it is, otherwise pass false. -// } +console.log(multiplyNums(5, 5, multiply)) + +function contains(item, list, cb) { + // contains checks if an item is present inside of the given array/list. + // Pass true to the callback if it is, otherwise pass false. +} // /* STRETCH PROBLEM */ From 0082d2ade9b2797fdd846454e27286172fdae235 Mon Sep 17 00:00:00 2001 From: toddmurphy Date: Tue, 15 Oct 2019 22:40:30 -0300 Subject: [PATCH 15/15] completed callbacks --- assignments/callbacks.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assignments/callbacks.js b/assignments/callbacks.js index 672490d3b..b026a4c10 100644 --- a/assignments/callbacks.js +++ b/assignments/callbacks.js @@ -50,10 +50,16 @@ function displayLength(name) { } displayLength('Todd') -function last(items, cb) { +function last(arr, cb) { + return cb(arr) // last passes the last item of the array into the callback. } +function lastItemArray(lastItemValue) { + return lastItemValue[lastItemValue.length - 1] +} +console.log(last(items, lastItemArray)) + function sumNums(num1, num2, cb) { // sumNums adds two numbers (x, y) and passes the result to the callback. return cb(num1, num2) @@ -67,6 +73,7 @@ console.log(sumNums(5, 5, add)) function multiplyNums(num1, num2, cb) { // multiplyNums multiplies two numbers and passes the result to the callback. + return cb(num1, num2) } @@ -79,6 +86,7 @@ console.log(multiplyNums(5, 5, multiply)) function contains(item, list, cb) { // contains checks if an item is present inside of the given array/list. // Pass true to the callback if it is, otherwise pass false. + return cb(list.includes(item)) } // /* STRETCH PROBLEM */