Passed the fourth test from exercise 04

This commit is contained in:
NetMan 2024-01-05 21:25:10 +01:00
parent 2d6400b9bb
commit f0c8df6081
2 changed files with 3 additions and 2 deletions

View File

@ -8,13 +8,14 @@ const removeFromArray = function(array, ...remove) {
} }
array.pop(); array.pop();
for (let i = 0; i < saveArray.length; i++) { for (let i = 0; i < saveArray.length; i++) {
array.push(saveArray[i]); array.push(saveArray[saveArray.length - 1 - i]);
} }
} }
}); });
return array; return array;
}; };
removeFromArray([1, 2, 3, 4], 7, 2);
// Do not edit below this line // Do not edit below this line
module.exports = removeFromArray; module.exports = removeFromArray;

View File

@ -10,7 +10,7 @@ describe('removeFromArray', () => {
test('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.skip('can remove all values', () => {