Hi,
So I’m having trouble referencing within an array that is a result of a database query.
I’ll simplify my problem to a dummy scenario so I have more chance of getting answers.
In the console log my db query result array comes up in this format (all values are strings):
thing1: “X”
thing2: “Y”
thing3: “Z”
I’m trying to get a text element #textOutput to display “X”, “Y”, or “Z” depending on whether thing1, thing2 or thing3 is inputted. This is what I have at the end of my code, but it doesn’t work:
let P = "thing1";
$w("#textOutput").text = item.P.toString();
Yet when I do:
$w("#textOutput").text = item.thing1.toString();
…the text element displays “X” as expected.
But I don’t want P to be hardcoded. I want to be able to reference it as:
item.P
if that makes sense.
What is the correct syntax/method for doing this?
Thank you!