Tell us what’s happening:
Can anybody tell me what is wrong with my code? It does’t seem to modify the arrays as I expected.
Your code so far
function dropElements(arr, func) {
var i = 0;
function removeElm(arrM, elm) {
var ind = arrM.indexOf(elm);
arrM.splice(ind, 1);
}
while (func===false) {
for(i = arr.length; i >-1 ; i--) {
if (func(arr[i])===false) {
removeElm(arr, arr[i]);
}
}
}
console.log("arr is now " + arr);
return arr[i];
}
dropElements([1, 2, 3], function(n) {return n < 3; });
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it/