Ignores non-present values
This commit is contained in:
parent
4250c06303
commit
1aa228d42c
|
@ -7,7 +7,9 @@ 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]);
|
||||||
myArray.splice(pos, 1);
|
if (pos >= 0) { //Is it a valid argument
|
||||||
|
myArray.splice(pos, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return myArray;
|
return myArray;
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe('removeFromArray', function() {
|
||||||
it('removes multiple values', function() {
|
it('removes multiple values', function() {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
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]);
|
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
xit('ignores non present values, but still works', function() {
|
xit('ignores non present values, but still works', function() {
|
||||||
|
|
Loading…
Reference in New Issue