# Adding a dynamic amount of values to a JavaScript Object Property

**URL:** https://discourse.nodered.org/t/adding-a-dynamic-amount-of-values-to-a-javascript-object-property/54806
**Category:** General
**Created:** [7 December 2021 04:21 UTC](https://discourse.nodered.org/t/adding-a-dynamic-amount-of-values-to-a-javascript-object-property/54806 "2021-12-07T04:21:27Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![tfuchs1987](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tfuchs1987/32/44508_2.png) [@tfuchs1987](https://discourse.nodered.org/u/tfuchs1987)
#### Post date: [7 December 2021 18:10 UTC](https://discourse.nodered.org/t/adding-a-dynamic-amount-of-values-to-a-javascript-object-property/54806/5 "2021-12-07T18:10:16Z")

</div>

`bakman2` I cannot thank you enough! Your solution works like a charm! To generate an unknown amount of property keys I just had to adjust a little bit of your code to let it act like the `push` method

```auto
msg.object = [{ property: { }}];

for (let i = 0 ; i<5; i++){
msg.object[0].property["key_" +i] = "value_"+i;
}

return msg;

```

![66351358f3618512](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/02e35519ff475d88a9e60f0568621554753f2a7f.png)

I am so glad the node-red community is that awesome 🙌

---

_[View the full topic](https://discourse.nodered.org/t/adding-a-dynamic-amount-of-values-to-a-javascript-object-property/54806)._
