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..64cd4b9c3 --- /dev/null +++ b/checkpoint2.js @@ -0,0 +1,57 @@ +'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 + } + }, +]; + +// 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()); 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",