I am trying to populate a JSON object by automatically setting the keys for an JSON object based on the string value of another array. For example,
var test = ["a","b"]
{test[0]:"A"}
However, I get a Syntax error when I do this, if I manually set the value as the string as shown in the third line {"a":"A"}
this issue does not happen. I've checked that test[0]
does indeed print out "a"
and its datatype is a string. Is there any reason why this might be happening?