From d1247a163f6ad0be42475ff7538a7c431c146205 Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Thu, 23 Apr 2020 22:52:06 -0500 Subject: [PATCH 1/8] npm install and test:watch working ok --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f61169392..12f52352a 100644 --- a/index.js +++ b/index.js @@ -358,7 +358,7 @@ if (typeof exports !== 'undefined') { if (processSum) { module.exports.processSum = processSum } if (processProduct) { module.exports.processProduct = processProduct } if (processDuplicateFree) { module.exports.processDuplicateFree = processDuplicateFree } - if (lowerCaseStrings ) { module.exports.lowerCaseStrings = lowerCaseStrings} + if (lowerCaseStrings) { module.exports.lowerCaseStrings = lowerCaseStrings } if (isItAnApple) { module.exports.isItAnApple = isItAnApple } if (removeApple) { module.exports.removeApple = removeApple } if (stringSmash) { module.exports.stringSmash = stringSmash } From bbb5df15b28796941e15b0134885779817adfe2f Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 12:17:39 -0500 Subject: [PATCH 2/8] passed first processLength function --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 12f52352a..2e2bcffc8 100644 --- a/index.js +++ b/index.js @@ -48,8 +48,8 @@ function processFirstItem(stringList, callback) { * [2] Invoking `processLength` passing `[]` and `(num) => "There are " + num`, * should return "There are 0". */ -function processLength(/* CODE HERE */) { - /* CODE HERE */ +function processLength(list, callback) { + return callback(list.length); } /** @@ -66,8 +66,8 @@ function processLength(/* CODE HERE */) { * Invoking `processLastItem` passing `['foo', 'bar']` and `(str) => str + str`, * should return 'barbar'. */ -function processLastItem(/* CODE HERE */) { - /* CODE HERE */ +function processLastItem(stringList, callback) { + return callback([stringList.length - 1]); } /** From 432e465dbe7d7c7cfda39f26fb4cd4fb18e49970 Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 12:21:49 -0500 Subject: [PATCH 3/8] passed processLastItem function --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 2e2bcffc8..d28b71ffa 100644 --- a/index.js +++ b/index.js @@ -67,7 +67,7 @@ function processLength(list, callback) { * should return 'barbar'. */ function processLastItem(stringList, callback) { - return callback([stringList.length - 1]); + return callback(stringList[stringList.length - 1]); } /** From e251c7e3a09dcd526eb45a3ae17fc93a9fbdeb66 Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 12:28:20 -0500 Subject: [PATCH 4/8] passed processSum function --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d28b71ffa..1e1975792 100644 --- a/index.js +++ b/index.js @@ -88,8 +88,8 @@ function processLastItem(stringList, callback) { * [2] Invoking `processSum` passing `-5`, '-1', and `(num) => num + 1000`, * should return 994. */ -function processSum(/* CODE HERE */) { - /* CODE HERE */ +function processSum(num1, num2, callback) { + return callback(num1 + num2); } /** From 058384b4447651e8b1757fb75f4c2080ecc03f92 Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 12:33:15 -0500 Subject: [PATCH 5/8] passed processProduct function --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1e1975792..fe4476628 100644 --- a/index.js +++ b/index.js @@ -110,8 +110,8 @@ function processSum(num1, num2, callback) { * [2] Invoking `processProduct` passing 25 and 0 and `(num) => num + 1000`, * should return 1000. */ -function processProduct(/* CODE HERE */) { - /* CODE HERE */ +function processProduct(num1, num2, callback) { + return callback(num1 * num2); } /** From 957b31a6e3ca672412efa3fc95c056cd1884d15e Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 13:25:55 -0500 Subject: [PATCH 6/8] passed processDuplicateFree function twice --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fe4476628..60add54d2 100644 --- a/index.js +++ b/index.js @@ -132,8 +132,9 @@ function processProduct(num1, num2, callback) { * [2] Invoking `processDuplicateFree` passing `[1,1,2,2,3]` and `(arr) => arr.length`, * should return 3. */ -function processDuplicateFree(/* CODE HERE ONLY AFTER COMPLETING ALL OTHER TASKS */) { - /* CODE HERE ONLY AFTER COMPLETING ALL OTHER TASKS */ +function processDuplicateFree(list, callback) { + let DupeFreeSet = new Set(list); + return callback(Array.from(DupeFreeSet)); } /////////////// HIGHER-ORDER ARRAY METHODS /////////////// From 0e57a970f15f09ab9ce9c6f10590ac69e8e41855 Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 14:27:21 -0500 Subject: [PATCH 7/8] passed lowerCaseStrings function --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 60add54d2..1fb597ca3 100644 --- a/index.js +++ b/index.js @@ -156,8 +156,10 @@ function processDuplicateFree(list, callback) { * * [2] Invoking `lowerCaseStrings` with `['a', 'b', 'c' ]` will return `[ 'a', 'b', 'c' ]`. */ -function lowerCaseStrings(/* code here */) { - /* code here */ +function lowerCaseStrings(strings) { + let LCstrings = []; + strings.forEach(strings => { LCstrings.push(strings.toLowerCase()) }); + return LCstrings; } /** From 6e1c14220b7bc3ba8bb69ff749d64b5a50c9906f Mon Sep 17 00:00:00 2001 From: JenVest2020 Date: Mon, 27 Apr 2020 18:16:58 -0500 Subject: [PATCH 8/8] passed isItAnApple through to stringSmash function --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 1fb597ca3..bf50c21e9 100644 --- a/index.js +++ b/index.js @@ -177,8 +177,8 @@ function lowerCaseStrings(strings) { * * [2] Invoking `isItAnApple` with `['a', 'b', 'c' ]` will return `[ false, false, false ]`. */ -function isItAnApple(/* code here */) { - /* code here */ +function isItAnApple(strings) { + return strings.map(strings => (strings === 'apple') ? true : false); } /** @@ -197,8 +197,8 @@ function isItAnApple(/* code here */) { * * [2] Invoking `removeApple` with `['a', 'b', 'c' ]` will return `[ 'a', 'b', 'c' ]`. */ -function removeApple(/* code here */) { - /* code here */ +function removeApple(strings) { + return strings.filter(strings => strings != 'apple'); } /** @@ -216,8 +216,8 @@ function removeApple(/* code here */) { * * [2] Invoking `stringSmash` with `['a', 'b', 'c' ]` will return `abc`. */ -function stringSmash(/* code here */) { - /* code here */ +function stringSmash(strings) { + return strings.reduce((first, last) => first += last); } // A local community center is holding a fund raising 5k fun run and has invited