8000 finished removeFromArray · borason/javascript-exercises@f610488 · GitHub
[go: up one dir, main page]

Skip to content

Commit f610488

Browse files
committed
finished removeFromArray
1 parent 6cdd20b commit f610488

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

removeFromArray/removeFromArray.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const removeFromArray = function() {
1+
const removeFromArray = function(array, ...args) {
2+
array = array.filter(x => !args.includes(x));
3+
return array;
4+
};
25

3-
}
4-
5-
module.exports = removeFromArray
6+
module.exports = removeFromArray;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
const removeFromArray = require('./removeFromArray')
1+
const removeFromArray = require("./removeFromArray");
22

3-
describe('removeFromArray', function() {
4-
it('removes a single value', function() {
3+
describe("removeFromArray", function() {
4+
it("removes a single value", function() {
55
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
66
});
7-
xit('removes multiple values', function() {
7+
it("removes multiple values", function() {
88
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
99
});
10-
xit('ignores non present values', function() {
10+
it("ignores non present values", function() {
1111
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
1212
});
13-
xit('ignores non present values, but still works', function() {
13+
it("ignores non present values, but still works", function() {
1414
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
1515
});
16-
xit('can remove all values', function() {
16+
it("can remove all values", function() {
1717
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
1818
});
19-
xit('works with strings', function() {
19+
it("works with strings", function() {
2020
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
2121
});
2222
});

0 commit comments

Comments
 (0)
0