I have a JSON object that goes somewhat like this:
var waitingGames = {
arithemetic:[
{
games:[]
},
{
games:[]
},
{
games:[]
}
]
and so on for synonyms, antonyms and translation. My problem is that I can't seem to access the games array by using this:
var gametype = url_parts.query.type;
var gamesize = url_parts.query.size;
if(games.waitingGames.gametype[gamesize].games.length == 0)
I get that gametype is undefined, even though I already tried printing the variable and it has the right value (arithemetic in the above example). Any ideas how to fix this?
object[variableName]. It makes sense that dot-notation wouldn't work sinceobject.variableNameimplies that there is a property of the object namedvariableName, when it should bekeyName, which is just stored in the variable.