Array Object Variable

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?

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

You can try it like:

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.

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

This is just an object, not an array.

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