From 0ac54f8f9e9ac2b13d48d23ad5720bb16a487804 Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 22 Apr 2020 21:02:07 -0500 Subject: [PATCH 1/4] 3 down and theywere pretty easy --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index f61169392..fc6355903 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,9 @@ 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) { + const stringNum = stringList.length - 1; + return callback(stringList[stringNum]) } /** From db1735dd008d01db44dc6d287c08d97c35dda561 Mon Sep 17 00:00:00 2001 From: dustin Date: Thu, 23 Apr 2020 19:52:22 -0500 Subject: [PATCH 2/4] got another one --- index.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index fc6355903..2dd7beacc 100644 --- a/index.js +++ b/index.js @@ -89,8 +89,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); } /** @@ -111,8 +111,8 @@ function processSum(/* CODE HERE */) { * [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) } /** @@ -156,9 +156,14 @@ function processDuplicateFree(/* CODE HERE ONLY AFTER COMPLETING ALL OTHER TASKS * * [2] Invoking `lowerCaseStrings` with `['a', 'b', 'c' ]` will return `[ 'a', 'b', 'c' ]`. */ -function lowerCaseStrings(/* code here */) { - /* code here */ -} +function lowerCaseStrings(strings,) { +const stringArr = []; + strings.forEach((strings) => { + stringArr.push(strings.toLowerCase()); + }) +return stringArr; +}; + /** * ### Challenge `isItAnApple` @@ -175,10 +180,12 @@ function lowerCaseStrings(/* code here */) { * * [2] Invoking `isItAnApple` with `['a', 'b', 'c' ]` will return `[ false, false, false ]`. */ -function isItAnApple(/* code here */) { - /* code here */ -} +function isItAnApple(strings) { + + const appStr = strings.map( 'apple'? true : false) + return appStr +} /** * ### Challenge `removeApple` * @@ -214,8 +221,8 @@ function removeApple(/* code here */) { * * [2] Invoking `stringSmash` with `['a', 'b', 'c' ]` will return `abc`. */ -function stringSmash(/* code here */) { - /* code here */ +function stringSmash(strings) { + } // A local community center is holding a fund raising 5k fun run and has invited @@ -233,7 +240,7 @@ function stringSmash(/* code here */) { * @returns an array with all the runners' full names in the following format: "Smith, John". * The full names appear in the array in the same order the runners appear in the `runners` array. */ -function getFullNames(/* CODE HERE */) { +function getFullNames(runners) { /* CODE HERE */ } From 1791cc2ba1a375b509891f180c43c9f43e293af3 Mon Sep 17 00:00:00 2001 From: dustin Date: Fri, 24 Apr 2020 19:10:35 -0500 Subject: [PATCH 3/4] theres another one --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 2dd7beacc..449b42f78 100644 --- a/index.js +++ b/index.js @@ -182,9 +182,9 @@ return stringArr; */ function isItAnApple(strings) { - const appStr = strings.map( 'apple'? true : false) + return( strings.map(strings => strings === 'apple' ? true : false)) - return appStr + } /** * ### Challenge `removeApple` @@ -202,8 +202,10 @@ function isItAnApple(strings) { * * [2] Invoking `removeApple` with `['a', 'b', 'c' ]` will return `[ 'a', 'b', 'c' ]`. */ -function removeApple(/* code here */) { - /* code here */ +function removeApple(strings) { + + return (strings.filter(string => string !== 'apple') + ) } /** @@ -222,7 +224,7 @@ function removeApple(/* code here */) { * [2] Invoking `stringSmash` with `['a', 'b', 'c' ]` will return `abc`. */ function stringSmash(strings) { - +return (strings.reduce()) } // A local community center is holding a fund raising 5k fun run and has invited From 36a11bf616b8088130504fe5cd4b97d676be64fb Mon Sep 17 00:00:00 2001 From: dustin Date: Fri, 24 Apr 2020 22:04:54 -0500 Subject: [PATCH 4/4] all done --- index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 449b42f78..833f3628a 100644 --- a/index.js +++ b/index.js @@ -224,9 +224,10 @@ function removeApple(strings) { * [2] Invoking `stringSmash` with `['a', 'b', 'c' ]` will return `abc`. */ function stringSmash(strings) { -return (strings.reduce()) +return strings.reduce((string,start)=>{return string += start},[]); } + // A local community center is holding a fund raising 5k fun run and has invited // 50 small businesses to make a small donation on their behalf for some much needed // updates to their facilities. Each business has assigned a representative @@ -243,7 +244,7 @@ return (strings.reduce()) * The full names appear in the array in the same order the runners appear in the `runners` array. */ function getFullNames(runners) { - /* CODE HERE */ + return (runners.map(arr => arr.last_name + ', ' + arr.first_name)) } /** @@ -258,8 +259,8 @@ function getFullNames(runners) { * @returns an array with all the runners' first names in ALL CAPS. * The first names appear in the array in the same order the runners appear in the `runners` array. */ -function firstNamesAllCaps(/* CODE HERE */) { - /* CODE HERE */ +function firstNamesAllCaps(runners) { + return runners.map(names => names.first_name.toUpperCase()) } /** @@ -276,8 +277,8 @@ function firstNamesAllCaps(/* CODE HERE */) { * @returns an array containing only the runners that use the given `tShirtSize`. * The runners in the array appear in the same order they appear in the `runners` array. */ -function getRunnersByTShirtSize(/* CODE HERE */) { - /* CODE HERE */ +function getRunnersByTShirtSize(runners, tShirtSize) { + return (runners.filter(person => person.shirt_size === tShirtSize)) } /**