Passed final test from exercise 04

This commit is contained in:
NetMan 2024-01-05 21:34:14 +01:00
parent 1d72ec8b14
commit a308d40fee
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
const removeFromArray = function(array, ...remove) { const removeFromArray = function(array, ...remove) {
remove.forEach(element => { remove.forEach(element => {
let findIndexElement = array.findIndex(x => x == element); let findIndexElement = array.findIndex(x => x === element);
if (findIndexElement >= 0) { if (findIndexElement >= 0) {
let saveArray = []; let saveArray = [];
for (let i = 0, arrayLength = array.length; i < arrayLength - findIndexElement - 1; i++) { for (let i = 0, arrayLength = array.length; i < arrayLength - findIndexElement - 1; i++) {

View File

@ -19,7 +19,7 @@ describe('removeFromArray', () => {
test('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]);
}); });
}); });