From f5fea2adf3d412f0b249ec8f1630c21708e12de7 Mon Sep 17 00:00:00 2001 From: Andres Garcia Date: Sat, 28 Mar 2020 18:46:18 -0500 Subject: [PATCH] Solution --- removeFromArray/removeFromArray.js | 13 +++++++++++-- removeFromArray/removeFromArray.spec.js | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/removeFromArray/removeFromArray.js b/removeFromArray/removeFromArray.js index 11efd5c..f0d6904 100644 --- a/removeFromArray/removeFromArray.js +++ b/removeFromArray/removeFromArray.js @@ -1,5 +1,14 @@ -const removeFromArray = function() { +let removeFromArray = function(...args) { + let array = args[0]; -} + const newArray = []; + + array.forEach((item) => { + if (!args.includes(item)) { + newArray.push(item); + } + }); + return newArray; +}; module.exports = removeFromArray diff --git a/removeFromArray/removeFromArray.spec.js b/removeFromArray/removeFromArray.spec.js index 28c744c..6185342 100644 --- a/removeFromArray/removeFromArray.spec.js +++ b/removeFromArray/removeFromArray.spec.js @@ -4,19 +4,19 @@ describe('removeFromArray', function() { it('removes a single value', function() { expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]); }); - xit('removes multiple values', function() { + it('removes multiple values', function() { expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]); }); - xit('ignores non present values', function() { + it('ignores non present values', function() { expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]); }); - xit('ignores non present values, but still works', function() { + it('ignores non present values, but still works', function() { expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]); }); - xit('can remove all values', function() { + it('can remove all values', function() { expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]); }); - xit('works with strings', function() { + it('works with strings', function() { expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]); }); });