diff --git a/index.js b/index.js index 00a3d90..95f9827 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ - //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` //`array` must be an array @@ -11,7 +10,15 @@ //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 myNewArray=[]; + for(let i = 0; i=0; i--){ + myNewArray.push(theArray[i]); + } + return myNewArray; } //create a new array @@ -62,7 +84,11 @@ function reverse(theArray){ //add the item from each loop to the new array except the first item //return the new array function tail(theArray){ - + myNewArray = []; + for(let i = theArray.length[1]; i theArray[j]){ + holder = theArray[i]; + theArray[i] = theArray[j]; + theArray[j] = holder; + } + } + } + return theArray; } exports.map = map; @@ -87,3 +123,4 @@ exports.reverse = reverse; exports.tail = tail; exports.sort = sort; exports.findLast = findLast; +