Drop It algorithm

This challenge has a bug in it.

This should work:

const dropElements = (arr, func) => {
  get_remaining_elements = false;
  return arr.reduce((a, b) => {
      get_remaining_elements = get_remaining_elements ? true : func(b);
      return get_remaining_elements ? [...a, b] : a;
  }, []);
}

But I get:

Which is clearly wrong.

1 Like

you didn’t define it before using it, the error you get is correct
strict mode, which is active in the fcc editor, impose that you must declare all your variables

I probably should have made my own thread for this. Can you move my post to a new thread?

1 Like

@kerafyrm to elaborate this further, you can read this paragraph - http://speakingjs.com/es5/ch07.html#_variables_must_be_declared_in_strict_mode