Markdown preview: challenge font-end

toggle (min/max) button only works once? can’t use it twice. why?

1 Like

I explain it for the editor window. You are never removing the event listener for reset(). In line 38 you just remove the class that you use as a target for setting the event listener in line 21. But the event listener still exists! Check it out by simply adding a console.log("reset called"); inside your reset() function and click on maximize a few times.

To solve this problem you need to remove the reset event listener from both maximize buttons after you minimized, not just the class that you use to target. You dont set event listeners on classes. You set them on elements. If the class is gone, the element still exists.

Removing an event listener works the same way as adding one. Guess what the call for it looks like… :wink:

1 Like