help::Drop it ------

Tell us what’s happening:
passes every test except this one " dropElements([1, 2, 3, 4], function(n) {return n > 5;}) should return "

any hints or advice?
Your code so far

function dropElements(arr, func) {
 var t = [...arr]

for(var i =0;i<t.length;i++){




return t

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

console.log(dropElements([1, 2, 3, 4], function(n) {return n > 5;}))

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

console.log(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}))

console.log(([1, 2, 3, 4], function(n) {return n > 5;}))
   **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:

Add this line to your for loop to discover the issue yourself.


If you want a more detailed hint read below…

Your for loop will loop as many times as the length of your t array. But since you’re shifting values off the array, the length is shortened. So what you end up with is the loop not running to original array length like you intended.

1 Like

thanks that really helped

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