From f1149c3915a18ef1b44bc2c7ebd1cccc282b82dc Mon Sep 17 00:00:00 2001 From: marleyrae Date: Mon, 19 Jun 2023 16:03:48 -0700 Subject: [PATCH] Make 04 tests pass --- 04_removeFromArray/removeFromArray.js | 8 ++--- 04_removeFromArray/removeFromArray.spec.js | 42 +++++++++++----------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/04_removeFromArray/removeFromArray.js b/04_removeFromArray/removeFromArray.js index 1bedeb0..195342a 100644 --- a/04_removeFromArray/removeFromArray.js +++ b/04_removeFromArray/removeFromArray.js @@ -1,6 +1,6 @@ -const removeFromArray = function() { - -}; +const removeFromArray = function (array, ...remove) { + return array.filter(item => !remove.includes(item)) +} // Do not edit below this line -module.exports = removeFromArray; +module.exports = removeFromArray diff --git a/04_removeFromArray/removeFromArray.spec.js b/04_removeFromArray/removeFromArray.spec.js index 21f34cf..86e1a40 100644 --- a/04_removeFromArray/removeFromArray.spec.js +++ b/04_removeFromArray/removeFromArray.spec.js @@ -2,24 +2,24 @@ const removeFromArray = require('./removeFromArray') describe('removeFromArray', () => { test('removes a single value', () => { - expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]); - }); - test.skip('removes multiple values', () => { - expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]); - }); - test.skip('ignores non present values', () => { - expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]); - }); - test.skip('ignores non present values, but still works', () => { - expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]); - }); - test.skip('can remove all values', () => { - expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]); - }); - test.skip('works with strings', () => { - expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]); - }); - test.skip('only removes same type', () => { - expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]); - }); -}); + expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]) + }) + test('removes multiple values', () => { + expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]) + }) + test('ignores non present values', () => { + expect(removeFromArray([1, 2, 3, 4], 7, 'tacos')).toEqual([1, 2, 3, 4]) + }) + test('ignores non present values, but still works', () => { + expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]) + }) + test('can remove all values', () => { + expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]) + }) + test('works with strings', () => { + expect(removeFromArray(['hey', 2, 3, 'ho'], 'hey', 3)).toEqual([2, 'ho']) + }) + test('only removes same type', () => { + expect(removeFromArray([1, 2, 3], '1', 3)).toEqual([1, 2]) + }) +})