From 73bc58dfe95ac1e561c3a5d2eb84ff1d5a1b84b0 Mon Sep 17 00:00:00 2001 From: douglasxtaylor Date: Mon, 11 Sep 2017 10:35:40 -0700 Subject: [PATCH] UNFINISHED: Had to work all weekend. Will complete this week. --- src/arrays.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/arrays.js b/src/arrays.js index b995952..eb70e77 100644 --- a/src/arrays.js +++ b/src/arrays.js @@ -8,11 +8,19 @@ const each = (elements, cb) => { // Iterates over a list of elements, yielding each in turn to the `cb` function. // This only needs to work with arrays. // based off http://underscorejs.org/#each + for (let i = 0; i < elements.length; i++) { + cb(elements[i], i); + } }; const map = (elements, cb) => { // Produces a new array of values by mapping each value in list through a transformation function (iteratee). // Return the new array. + const newArr = []; + for (let i = 0; i < elements.length; i++) { + newArr.push(cb(elements[i])); + } + return newArr; }; const reduce = (elements, cb, memo = elements.shift()) => {