← Practice
Functions·medium 18 min 75 XP

Custom Filter

Reimplement Array.prototype.filter as myFilter(array, predicate) without using the built-in .filter.

Examples

  • myFilter([1,2,3,4], x => x % 2 === 0) → [2,4]

Constraints

  • Keep the required function name so the tests can find it
  • Return a value instead of only logging it
  • Do not mutate inputs unless the challenge asks you to
Custom Filter · editor

Code runs in an isolated Web Worker with a 3-second timeout — no DOM access, and it can never hang the page.