Passed final test from exercise 04
This commit is contained in:
parent
1d72ec8b14
commit
a308d40fee
|
@ -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++) {
|
||||||
|
|
|
@ -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]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue