Passed the third test from exercise 04
This commit is contained in:
parent
553279a58a
commit
2d6400b9bb
|
@ -1,6 +1,7 @@
|
|||
const removeFromArray = function(array, ...remove) {
|
||||
remove.forEach(element => {
|
||||
let findIndexElement = array.findIndex(x => x == element);
|
||||
if (findIndexElement >= 0) {
|
||||
let saveArray = [];
|
||||
for (let i = 0; i < array.length - findIndexElement; i++) {
|
||||
saveArray.push(array.pop());
|
||||
|
@ -9,6 +10,7 @@ const removeFromArray = function(array, ...remove) {
|
|||
for (let i = 0; i < saveArray.length; i++) {
|
||||
array.push(saveArray[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return array;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('removeFromArray', () => {
|
|||
test('removes multiple values', () => {
|
||||
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]);
|
||||
});
|
||||
test.skip('ignores non present values, but still works', () => {
|
||||
|
|
Loading…
Reference in New Issue