passed all tests
This commit is contained in:
parent
2ea438b6e4
commit
8d116ded28
|
@ -1,17 +1,20 @@
|
||||||
// Almost passes test but doesn't return as array:
|
// PASSED ALL TESTS:
|
||||||
|
|
||||||
const removeFromArray = function([a, ...b], c, ...d) {
|
const removeFromArray = function([a, ...b], c, ...d) {
|
||||||
|
|
||||||
let firstArray = [a, ...b];
|
let firstArray = [a, ...b];
|
||||||
let secondArray = [c, ...d];
|
let secondArray = [c, ...d];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let combinedArray = [...firstArray, ...secondArray];
|
let combinedArray = [...firstArray, ...secondArray];
|
||||||
let removeDuplicates = [...new Set(combinedArray)]
|
let removeDuplicates = [...new Set(combinedArray)]
|
||||||
|
|
||||||
console.table(removeDuplicates)
|
let filterFirstArray = removeDuplicates.filter(n => !secondArray.includes(n))
|
||||||
}
|
|
||||||
|
|
||||||
removeFromArray(["a", "b", "c", "d"], "d", "e", "f", "g")
|
return filterFirstArray;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do not edit below this line
|
// Do not edit below this line
|
||||||
|
|
|
@ -4,22 +4,22 @@ describe('removeFromArray', () => {
|
||||||
test('removes a single value', () => {
|
test('removes a single value', () => {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
|
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
|
||||||
});
|
});
|
||||||
test.skip('removes multiple values', () => {
|
test('removes multiple values', () => {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
||||||
});
|
});
|
||||||
test.skip('ignores non present values', () => {
|
test('ignores non present values', () => {
|
||||||
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]);
|
||||||
});
|
});
|
||||||
test.skip('ignores non present values, but still works', () => {
|
test('ignores non present values, but still works', () => {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
|
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
|
||||||
});
|
});
|
||||||
test.skip('can remove all values', () => {
|
test('can remove all values', () => {
|
||||||
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
|
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
|
||||||
});
|
});
|
||||||
test.skip('works with strings', () => {
|
test('works with strings', () => {
|
||||||
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
||||||
});
|
});
|
||||||
test.skip('only removes same type', () => {
|
test('only removes same type', () => {
|
||||||
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