0
votes

I am trying to assign true/ false using for loop

    for (i=1;i<31;i++){
            _global.level + i + Access = true;
    }

and got error as "Left side of assignment operator must be variable or property" any help

3
try _global["level" + i].Access - mgraph

3 Answers

0
votes

If you want to set the value for properties like level1Access, level2Access ... give

_global["level" + i + "Access"] = true;

or if the properties are like level1.Access, level2.Access ... give

_global["level" + i].Access = true;

or if Access is another variable

_global["level" + i + Access] = true;
0
votes

The left hand side needs to be a single variable. When you say _global.level + i + Access = true; what do you expect to happen? Which variable should be assigned to true?

0
votes

Look at what the error is telling you. Is this a variable or property

_global.level + i + Access //the left hand side of the assignment

Until more detail about what level and Access are is given there's not much help we can give.

A solution might be, (making a guess that level is and array and Access is a property)

_global.level[i].Access = true;