From df0662d8f8bca0fe0405fb99f142aa58f5c2377e Mon Sep 17 00:00:00 2001 From: Selena Solis Date: Wed, 10 Jul 2019 18:19:11 -0500 Subject: [PATCH 1/5] initial aca-dash --- index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/index.js b/index.js index 00a3d90..d53c469 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,23 @@ //iteratee is a function that must return something, capture whatever it returns in a variable //add the returned value from iteratee tp myNewArray //after looping, return myNewArray + +let array1 = [1,3,5,7]; function map(array, iteratee){ + console.log(array); + let newArr = []; + for(let i=0; i 5; } +filter(array1, iteratee2); //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find //create a function called `find`, it should take 2 parameters `theArray` and `fnc` //loop theArray and call the fnc for each thing in the array, From e82dc4053a92fe07e277b1a06b59ccb7e4c5bcee Mon Sep 17 00:00:00 2001 From: Selena Solis Date: Wed, 10 Jul 2019 19:56:54 -0500 Subject: [PATCH 2/5] added functions --- index.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index d53c469..bf521be 100644 --- a/index.js +++ b/index.js @@ -12,21 +12,23 @@ //add the returned value from iteratee tp myNewArray //after looping, return myNewArray -let array1 = [1,3,5,7]; +let array1 = [11,3,5,8,4]; +console.log(array1); function map(array, iteratee){ - console.log(array); let newArr = []; for(let i=0; i 5; } -filter(array1, iteratee2); +filter(array1, iteratee2); //output: [11,8] //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find //create a function called `find`, it should take 2 parameters `theArray` and `fnc` //loop theArray and call the fnc for each thing in the array, @@ -60,36 +64,72 @@ filter(array1, iteratee2); //fnc will return true or false, if true return the item //after looping, return null function find(theArray, fnc){ + for(let i=0; i=0; i--){ + newArr.push(theArray[i]); + } + console.log(newArr); + return newArr; } +reverse(array1); //output: [4,8,5,3,11] + + //create a new array //loop theArray //add the item from each loop to the new array except the first item //return the new array function tail(theArray){ - + let newArr = []; + for(let i=1; i theArray[i+1]){ + let temp = theArray[i]; + theArray[i] = theArray[i+1]; + theArray[i+1] = temp; + swapped = true; + } + } + if(swapped){ + sort(theArray); + } + else{ + console.log(theArray); + return theArray; + } } +sort(array1); //output: [3,4,5,8,11] + exports.map = map; exports.filter = filter; exports.find = find; From 03f9c8302884b9c82f88ae0028f754a0973dc911 Mon Sep 17 00:00:00 2001 From: Selena Solis Date: Fri, 12 Jul 2019 14:45:06 -0500 Subject: [PATCH 3/5] folder name change --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index bf521be..af0ce03 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map //create a function called `map`, it should take 2 parameters `array` and `iteratee` @@ -23,7 +24,7 @@ function map(array, iteratee){ return newArr; } -//adds 5 to each item in array +//adds 5 to an item function iteratee1(item){ return item + 5; } @@ -74,7 +75,7 @@ function find(theArray, fnc){ } } -//function find the first item in an array that is less than 5 +//function returns true if item is less than 5 function fnc1(item){ return item < 5; } @@ -91,7 +92,7 @@ function findLast(theArray){ findLast(array1); //output: 4 -//return the first element of the array +//return the first element of an array function head(theArray){ console.log(theArray[0]); return theArray[0]; From d6cc039e635f17fc2198d304b9c098c596c65ad3 Mon Sep 17 00:00:00 2001 From: Selena Solis Date: Fri, 12 Jul 2019 17:47:33 -0500 Subject: [PATCH 4/5] formatting --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index af0ce03..c6f264e 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -#!/usr/bin/env node //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map //create a function called `map`, it should take 2 parameters `array` and `iteratee` From d565dd34c2c768842d1b8fc25fb15fd5653219b7 Mon Sep 17 00:00:00 2001 From: Selena Solis Date: Fri, 12 Jul 2019 20:34:28 -0500 Subject: [PATCH 5/5] gitignore --- .gitignore | 3 +++ packageTest.js | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 .gitignore create mode 100644 packageTest.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ad007c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +package.json \ No newline at end of file diff --git a/packageTest.js b/packageTest.js new file mode 100644 index 0000000..17d1664 --- /dev/null +++ b/packageTest.js @@ -0,0 +1,6 @@ +let dash = require("aca-dash-selena-solis"); + +let array1 = [11,3,5,8,4]; + +let headOfArr = dash.head(array1); +console.log(headOfArr);