Intermediate Algorithm Scripting: Drop it - Test Cases Wonky?

Tell us what’s happening:

The criteria seem to be off here…

dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1] .

n === 1 should only return 1, shouldn’t it? No zeroes?

dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2] .

n > 2 shouldn’t include 2 at all, and not sure why it’s allowing duplicates for either of these (1s, or 2s). Am I missing something?

Your code so far


function dropElements(arr, func) {
// Drop them elements.
let copy = [].concat(...arr);  
let popped = [];
//for (let i=0;i<=arr.length+1;i++) 
copy.map (n => { 
  let popper = arr.shift();
  
  if (func(popper)) {
    console.log(true);
    if (popped.includes(popper) == false) {
      popped.push(popper)
    }
    
  } else {
    console.log(false);
    
  }
  
})
console.log(arr);
console.log(popped);
return popped; 
}

dropElements([0, 1, 0, 1], function(n) {return n === 1;});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Drop it

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it

read again the cchallenge description, it says to remove items from the array until the first one that satisfies the test case, and then keep the rest of the array

Given the array arr , iterate through and remove each element starting from the first element (the 0 index) until the function func returns true when the iterated element is passed through it.

Then return the rest of the array once the condition is satisfied, otherwise, arr should be returned as an empty array.

Everything prior to the first 1 should be dropped. Everything in the array from that point on should be returned.

you are supposed to return every number in the array after the first number which returns true
for example. in
dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2] .
first number greater than 2 is 3 so you are supposed to return 3 and every other number after 3