[Solved] Array length dubt

Hello, i have this code,
clearLevel: function() { var self=this; if (self.game.descend===true) { var lev=self.player.depth-2; } else { var lev=self.player.depth; } for (var i=0; i<self.game.doorLocations[lev].length;i++) { self.game.doorLocations[lev][i].enabled=false; } }
but when reach the for instruction the length of the array is not returned so the entities are not disabled. Where am i wrong?

Does game.doorLocations[lev] return a valid array? (you can either breakpoint here or print it to the console)

Seems that lev variable is undefined as firefox says that don’t make sense now will try with chrome

That’s what chrome show
EDIT: Seems my problem is even more complex, keeping the levels layout and make the player goes up and down is driving me crazy.

If lev is undefined, then you have to look where that value is assigned and/or changed. In the code snippet you have posted, I would check self.player.depth