Why the output is not correct

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)){
  }/*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:

Is this piece of code right?

The challenge says : until function func returns true
This means if it turns true once, return it immediately and keep whatever comes next


If I uncomment the else part it solved the challenge.

Thank you @mientje for this clarification.


Yes, you found it that’s what I me by that

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.