# Array Object Variable

**URL:** https://discourse.nodered.org/t/array-object-variable/35239
**Category:** General
**Created:** [2 November 2020 20:29 UTC](https://discourse.nodered.org/t/array-object-variable/35239 "2020-11-02T20:29:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mdeluca1992](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mdeluca1992](https://discourse.nodered.org/u/mdeluca1992)
#### Post date: [2 November 2020 20:29 UTC](https://discourse.nodered.org/t/array-object-variable/35239/1 "2020-11-02T20:29:29Z")

</div>

I am trying to build an object array using two variables. Below is an example of what I am trying to do. Variables text1 and text2. When I look in the debug window the array object has the variable and not the text I defined at the top of the function window. How can i get the "text1" variable to be replaced with the value I defined in the variable section?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6869d2d027e8d39cf56f3b97507c7d19ab6254e3.png)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [2 November 2020 20:57 UTC](https://discourse.nodered.org/t/array-object-variable/35239/2 "2020-11-02T20:57:10Z")

</div>

text1 is a string with a space, it will fail trying to set it.

You can try it like:

```auto
msg.final_array = {[text1]: text2}

```

This will expand it. Note that this will not be easily accessible.  
Would recommend to use properties that describe the content, ie.

```auto
{"label" : "Test 1", "value" : "Test 2" }

```

This is just an object, not an array.

---

<div class="post-metadata">

### Author: ![mdeluca1992](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mdeluca1992](https://discourse.nodered.org/u/mdeluca1992)
#### Post date: [2 November 2020 21:30 UTC](https://discourse.nodered.org/t/array-object-variable/35239/3 "2020-11-02T21:30:15Z")

</div>

Thank you this helped me out! Putting the around the variable did exactly what I was looking to do.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [1 January 2021 21:30 UTC](https://discourse.nodered.org/t/array-object-variable/35239/4 "2021-01-01T21:30:16Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
