Tell us what’s happening:
For this challenge, somethings are unclear for me.
Why the output for these tests shouldn’t be (last twice lines) : [1,1] instead of [1,0,1]
and [3,9,2] instead [3,9].
Thanks a lot for your feedbacks.
**Your code so far**
function dropElements(arr, func) {
let result = [];
arr.filter( value =>{
if (func(value)){
result.push(value);
}/*else {
if (result.length > 0) result.push(value);
}*/
});
return result;
}
console.log(dropElements([0, 1, 0, 1], function(n) {return n === 1;})); //[1, 1] ?
console.log(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})); // [3, 9]?
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
.
Challenge: Drop it
Link to the challenge: