$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #112

What is the correct fix?

el.addEventListener('scroll', () => heavy());
// later
el.removeEventListener('scroll', () => heavy());
  1. Keep one named handler and remove that
  2. Keep one inline arrow and remove that
  3. Pass { once: true } to the remove call
  4. Call el.removeEventListener('scroll')
The two arrows are different function objects, so the listener is never removed.
Play Problem Solving ▸