10000 complete exercise #04 · jpawz/javascript-exercises@f1514c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f1514c6

Browse files
committed
complete exercise TheOdinProject#4
1 parent 6a61b3e commit f1514c6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

04_removeFromArray/removeFromArray.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
const removeFromArray = function() {
2-
1+
const removeFromArray = function(arr, ...items) {
2+
let filteredArray = arr;
3+
items.forEach((item) => filteredArray = filteredArray.filter((i) => i !== item));
4+
return filteredArray;
35
};
46

57
// Do not edit below this line

04_removeFromArray/removeFromArray.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ describe('removeFromArray', () => {
44
test('removes a single value', () => {
55
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
66
});
7-
test.skip('removes multiple values', () => {
7+
test('removes multiple values', () => {
88
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
99
});
10-
test.skip('ignores non present values', () => {
10+
test('ignores non present values', () => {
1111
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
1212
});
13-
test.skip('ignores non present values, but still works', () => {
13+
test('ignores non present values, but still works', () => {
1414
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
1515
});
16-
test.skip('can remove all values', () => {
16+
test('can remove all values', () => {
1717
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
1818
});
19-
test.skip('works with strings', () => {
19+
test('works with strings', () => {
2020
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
2121
});
22-
test.skip('only removes same type', () => {
22+
test('only removes same type', () => {
2323
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
2424
});
2525
});

0 commit comments

Comments
 (0)
0