Tell us what’s happening:
Describe your issue in detail here.
Your code so far
function dropElements(arr, func) {
let result=[];
for(let i=0;i<arr.length;i++){
if(func(arr[i])){
result.push(arr[i]);
}
}
console.log(result)
return result;
}
dropElements([1, 2, 3], function(n) {return n < 3; });
the test result is : // running tests
dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return
[1, 0, 1]
why not [1,1]???
.
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return
[3, 9, 2]
why not [3,9]???
. // tests completed // console output
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Drop it
Link to the challenge: