Alert box issues - not showing after function is called multiple times

So I am trying to code an AI for a connect 4 game I made, and I’m using alert boxes as I go to make sure everything is working as it should (as by play testing you cannot tell if most changes are working properly). When you are playing the game the ‘P’ variable will change, but this is all that is needed to create the issue. The alert should produce 7 alerts with scores each time the function is called, this happens the first time the function is called, but after that no alert box pops up, and no issues in the console (when using actual game files they pop up but say ‘undefined’, figured it is the same issue). Any ideas why?

var P = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,2,0];
var a = 0;
var c = 0;
var L = 0;
var move = [0, 0, 0, 0, 0, 0, 0];
var loc = [35, 36, 37, 31, 39, 33, 41];
var score = 0;

function error(){
	while( a < 7){
			var c = 0;
			L = loc[a] + 7;
			while( c < 3){
				if(L > 34){
					c = 4;
				}
				if(P[L] == 2){
					score = score + 1;
				}
				c = c + 1;
				L = L + 7;
			}
			move[a] = score;
			alert(move[a]);
			score = 0;
			a = a + 1;
	}
}

Strange…
Have you tried?:
alert(a);

instead of:
alert(move[a]);

‘a’ is a sepperate variable just used for the while loops (in this case the practical use is there are 7 column in connect four, so starting at 0 through to 6 it loops through for each column, and so having
alert(move[a]);
alerts the value for each column as the loop runs if that makes sense…)but it is very strange…

ok. if
alert(a)
is working correctly
and
alert(move[a])
is NOT working correctly then there must be an issue with move-array. Did you try?:
alert(move)

Hmm…just tried that then and after the first time it was called it gave back values that made no sense…might have to just re-write a lot of this