Functional programming is the answer. In python the answer is just this:
def action(thing)
...
map(action, array_of_things)
I'm sure there's some similar solution in Javascript.