# Using a for loop for dynamic objects

**URL:** <https://discourse.nodered.org/t/using-a-for-loop-for-dynamic-objects/53439>\
**Category:** General\
**Created:** [9 November 2021 09:42 UTC](https://discourse.nodered.org/t/using-a-for-loop-for-dynamic-objects/53439 "2021-11-09T09:42:06Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2021 12:14 UTC](https://discourse.nodered.org/t/using-a-for-loop-for-dynamic-objects/53439/10 "2021-11-09T12:14:42Z")

</div>

In future please post code using the method in this link. [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

You are overwriting msg.call the first time round the loop, which destroys what was there before, so the next time you execute that line there is no data there.  
Also you should not use `for in` for an array you should use `forEach()` or a simple `for` loop. [JavaScript Array Iteration](https://www.w3schools.com/js/js_array_iteration.asp)

Do you not want to use the map method? It is much simpler.

---

_[View the full topic](https://discourse.nodered.org/t/using-a-for-loop-for-dynamic-objects/53439)._
