Array indexOf() Reference Error?
Hello,
I have these simple code lines and on line 20 I'm getting the error in the comment but I cant find the problem in my code ![]()
var directions = [0,1,2,3];
var lockedDirection = 0;
var lastDirection = 2; // sample code
switch (lastDirection) {
case 0:
lockedDirection = 2;
break;
case 1:
lockedDirection = 3;
break;
case 2:
lockedDirection = 0;
break;
case 3:
lockedDirection = 1;
break;
};
var a = directions.indexOf(lockedDirection); // ReferenceError: Function directions.indexOf is undefined
directions.splice(a, 1);