Iterate over arrays

Iterate over arrays 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 have an array of user IDs and need to run an async check for each ID to refresh their cache.…
I have an array of user IDs and need to run an async check for each ID to refresh their cache. Iterate the array so each ID is processed and any errors are collected; do not block the event loop unnecessarily. Provide the pattern I can drop into my refreshUsers function that returns when all checks finish and includes per-ID success or error.

Improve — make it easier to accept

+
Before I use this iteration in the nightly job, make the approach obvious to the ops reviewer: show…
Before I use this iteration in the nightly job, make the approach obvious to the ops reviewer: show how to process IDs concurrently but with a maximum of five simultaneous requests, ensure errors for one ID don’t stop the rest, and return a summary of successes and failures. Keep the example concise and explain the concurrency choice in one sentence.

Decide — diagnose the stuck moment

+
I implemented a forEach over user IDs and added await inside its callback; the refresh never…

I started using forEach with await and tasks stalled

I implemented a forEach over user IDs and added await inside its callback; the refresh never completed. The job owner Jack will lose trust if the nightly run keeps hanging. I don’t know whether to switch to for...of, Promise.all, or a concurrency limiter. What caused the hang and what is the best fix that preserves concurrency control?

Become — change the pattern

+
Repeatedly on projects we write array.forEach with await or use Promise.all for thousands of items…

Iteration mistakes causing slow or broken jobs

Repeatedly on projects we write array.forEach with await or use Promise.all for thousands of items and blow memory or rate limits. It wastes hours in production incidents and postmortems. What single habit or small rule change will remove these errors: always use for...of with await, always limit concurrency, or prefer streaming APIs? Explain how to enforce it in code reviews and CI linters.

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.