diff --git a/index.js b/index.js index 00a3d90..094d54f 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,24 @@ //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 -function map(array, iteratee){ +let arr = [2,9,1,2,3,4,5,13]; + +function addFive (i) { + return i+5 } +function map(array, iteratee){ + let myNewArray = []; + for (let i=0; i=3) { + return true + } +} + +function filter(array, iteratee) { + let myNewArray = []; + for (let i=0; i4) { + return true; + } } +function find(theArray, fnc){ + for (let i=0; i=0; i--) { + reversedArr.push(theArray[i]) + } + console.log(reversedArr); } +reverse(newArr); + //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; itheArray[i+1]) { + theArray.splice([i],2,theArray[i+1],theArray[i]); + for (let j=1; jtheArray[j]) { + i=0 + } + } + } + } + console.log(theArray); } +sort(yarra); + exports.map = map; exports.filter = filter; exports.find = find;