Attach event listener

Attach event listener in JavaScript — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
I need this button on the product page to trigger the cart flow. Add an event listener so clicking…
I need this button on the product page to trigger the cart flow. Add an event listener so clicking Add to Cart calls addToCart with the product id, and ensure the listener is attached only once when the page initializes on Thursday morning.

Improve — make it easier to accept

+
Before I wire this up to procurement, make the click handler frictionless for reviewers: show the…
Before I wire this up to procurement, make the click handler frictionless for reviewers: show the product id where the handler is bound, put the actual callback name addToCart at the top, and flag any closures capturing large objects that could leak memory.

Decide — diagnose the stuck moment

+
I just attached the click handler for Add to Cart on the product page; QA reports the handler runs…

I wired the button and it's firing twice

I just attached the click handler for Add to Cart on the product page; QA reports the handler runs twice when clicked. I bound the listener inside the render function and the component re-renders; the product manager is waiting. I can't inspect the full render cycle in their staging environment. Likely cause and best fix to stop the duplicate calls?

Become — change the pattern

+
Across several pages we keep getting duplicated event handlers after users navigate back and forth.…

handlers multiply after repeated navigation

Across several pages we keep getting duplicated event handlers after users navigate back and forth. This costs time debugging and causes cart duplication bugs. Which habit should the team adopt to stop these regressions: where to register listeners, how to structure teardown, and one small lint or code-review rule to catch it early?

Next to this one

Other programming language work people do in JavaScript.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.