From 1d780bb1ef99f3148f08bdcf4b0a6dab37e48d5e Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Mon, 13 Nov 2017 18:15:45 -0600 Subject: [PATCH 1/2] i got dis --- 04week/functional-javascript/boilerPlate.js | 0 checkpoint2.js | 48 +++++++++++++++++++++ package-lock.json | 30 ++++++------- 3 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 04week/functional-javascript/boilerPlate.js create mode 100644 checkpoint2.js diff --git a/04week/functional-javascript/boilerPlate.js b/04week/functional-javascript/boilerPlate.js new file mode 100644 index 000000000..e69de29bb diff --git a/checkpoint2.js b/checkpoint2.js new file mode 100644 index 000000000..a3ff5ebf0 --- /dev/null +++ b/checkpoint2.js @@ -0,0 +1,48 @@ +'use strict'; + +// Take the following array of objects and console.log each user and their corresponding data in the following form: "user_name paid amount for product in city, state." using map. + + + +const userArray = [ + { + "customer": { + "id": 1, + "customerName":"Marilyn Monroe", + "customerCity":"New York City", + "customerState":"NY", + "product":"Yellow Chair", + "productPrice": 19.99 + } + }, + { + "customer": { + "id": 2, + "customerName":"Abraham Lincoln", + "customerCity":"Boston", + "customerState":"MA", + "product":"Movie Tickets", + "productPrice": 27.00 + } + }, + { + "customer": { + "id": 3, + "customerName":"John F. Kennedy", + "customerCity":"Dallas", + "customerState":"TX", + "product":"Mustang Convertible", + "productPrice": 24999.99 + } + }, + { + "customer": { + "id": 4, + "customerName":"Martin Luther King", + "customerCity":"Burmingham", + "customerState":"AL", + "product":"Sandwiches", + "productPrice": 7.99 + } + }, +]; diff --git a/package-lock.json b/package-lock.json index 62353c45d..f28cfa5c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,16 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "JSONStream": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", - "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", - "dev": true, - "requires": { - "jsonparse": "0.0.5", - "through": "2.3.8" - } - }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -2707,6 +2697,16 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, + "JSONStream": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", + "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", + "dev": true, + "requires": { + "jsonparse": "0.0.5", + "through": "2.3.8" + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -4367,6 +4367,11 @@ "through": "2.3.8" } }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, "string-to-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/string-to-stream/-/string-to-stream-1.1.0.tgz", @@ -4427,11 +4432,6 @@ } } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", From b87eb976082cbbd521109bf0ae391037e4a36420 Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Mon, 13 Nov 2017 19:07:42 -0600 Subject: [PATCH 2/2] that was easier than i thought --- checkpoint2.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/checkpoint2.js b/checkpoint2.js index a3ff5ebf0..64cd4b9c3 100644 --- a/checkpoint2.js +++ b/checkpoint2.js @@ -2,8 +2,6 @@ // Take the following array of objects and console.log each user and their corresponding data in the following form: "user_name paid amount for product in city, state." using map. - - const userArray = [ { "customer": { @@ -46,3 +44,14 @@ const userArray = [ } }, ]; + +// use userArray.map function and tick marks to print out in an array +// inside the .map function return the corresponding information listed above. +//return the array in a string so it looks cleaner using toString method. + +const customerSentence = userArray.map((entity) => { + return ` ${entity.customer.customerName} paid $${entity.customer.productPrice} for a ${entity.customer.product} in ${entity.customer.customerCity}, ${entity.customer.customerState}`; + +}); + +console.log(customerSentence.toString());