> For the complete documentation index, see [llms.txt](https://docs.syncmate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.syncmate.com/getting-started/actions/foreach.md).

# Foreach

Foreach action is just a more readable way of handling iteration over an array. Only thing to keep in mind is that **Iterate over** is JavaScript expression, if you want to reference data from other actions you need to use **ctx** object. **Iterator variable** on the other hand is not an expression but is just a name for output value that will be stored in **ctx** object.

<figure><img src="/files/IusXOz36xUCXxk1Rc5Rk" alt=""><figcaption></figcaption></figure>

### Iterator variable

Iterator variable is not an expression but a name for where to store the currently iterating item. With above example first item will be `ctx.product = ctx.products[0]` and so on for each iteration.
