add removeFromArray
This commit is contained in:
parent
fd5b062516
commit
4c8f1643ec
|
@ -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]
|
||||
```
|
|
@ -0,0 +1,5 @@
|
|||
var removeFromArray = function() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = removeFromArray
|
|
@ -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"]);
|
||||
});
|
||||
});
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue