Drop it 34675875875547

Drop it 34675875875547
0
#1

Don’t know why this isn’t working.

Your code so far


function dropElements(arr, func) {
  // Drop them elements.

var muppa = [];

for (let x = 0; x < arr.length; x++) {
  if (func(arr[x])) {
    muppa.push(arr[x]);
  } 
}

  return muppa;
}

dropElements([1, 2, 3], function(n) {return n < 3; });

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36.

#2

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.

You are returning only the elements thtat return true
instead you need to return the elements in the array from the first that return true to the end

with an array like [1, 2, 3] and condition n < 3, as the first element satisfy the condition you need to return the whole array.