From 4c8f1643ec2b539321a985d4d29441ddf66176c1 Mon Sep 17 00:00:00 2001 From: Cody Loyd Date: Thu, 24 Aug 2017 08:12:11 -0500 Subject: [PATCH] add removeFromArray --- 04-removeFromArray/README.md | 7 +++++++ 04-removeFromArray/removeFromArray.js | 5 +++++ 04-removeFromArray/removeFromArray.spec.js | 22 ++++++++++++++++++++++ README.md | 2 -- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 04-removeFromArray/README.md create mode 100644 04-removeFromArray/removeFromArray.js create mode 100644 04-removeFromArray/removeFromArray.spec.js diff --git a/04-removeFromArray/README.md b/04-removeFromArray/README.md new file mode 100644 index 0000000..b392417 --- /dev/null +++ b/04-removeFromArray/README.md @@ -0,0 +1,7 @@ +# Exercise 04 - removeFromArray + +Implement a function that takes an array and some other arguments then removes the other arguments from that array: + +```javascript +remove([1,2,3,4], 3) // should remove 3 and return [1,2,4] +``` \ No newline at end of file diff --git a/04-removeFromArray/removeFromArray.js b/04-removeFromArray/removeFromArray.js new file mode 100644 index 0000000..d36b8b1 --- /dev/null +++ b/04-removeFromArray/removeFromArray.js @@ -0,0 +1,5 @@ +var removeFromArray = function() { + +} + +module.exports = removeFromArray diff --git a/04-removeFromArray/removeFromArray.spec.js b/04-removeFromArray/removeFromArray.spec.js new file mode 100644 index 0000000..ff94e9a --- /dev/null +++ b/04-removeFromArray/removeFromArray.spec.js @@ -0,0 +1,22 @@ +var removeFromArray = require('./removeFromArray') + +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() { + expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]); + }); + xit('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() { + expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]); + }); + xit('can remove all values', function() { + expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]); + }); + xit('works with strings', function() { + expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]); + }); +}); diff --git a/README.md b/README.md index e10d4de..db6564d 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ The first exercise, `helloWorld` will walk you through the process in more depth 1. Caesar Cipher 1. Palindromes 1. Pangrams -1. Remove specific elements from array: remove([1,2,3,4], 3) <= remove 3 from that array -1. repeat string given number of times 1. sum numbers in range: sumAll(1,4) (sums all numbers between and including 1 and 4) 1. pig latin 1. fibonacci