All done
This commit is contained in:
parent
67402e5235
commit
1987591d9f
|
@ -7,7 +7,7 @@ const removeFromArray = function(...args) {
|
||||||
// Remove all the remaining elements from the array
|
// Remove all the remaining elements from the array
|
||||||
for (let i = 1; i < args.length; i++) {
|
for (let i = 1; i < args.length; i++) {
|
||||||
pos = myArray.indexOf(args[i]);
|
pos = myArray.indexOf(args[i]);
|
||||||
if (pos >= 0) { //Is it a valid argument
|
if (pos >= 0 && myArray[pos] === args[i]) { //Is it a valid argument
|
||||||
myArray.splice(pos, 1);
|
myArray.splice(pos, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ describe('removeFromArray', function() {
|
||||||
it('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]);
|
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([]);
|
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"]);
|
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
||||||
});
|
});
|
||||||
xit('only removes same type', function() {
|
it('only removes same type', function() {
|
||||||
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
|
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue