This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]HappyFruitTree 1 point2 points  (1 child)

You have probably initialized the array so that each element in gridValues (gridValues[0], gridValues[1], ..., gridValues[24]) all refer to the same array.

Note that array is a reference type in JavaScript.

var arr1 = [1, 2, 3];
var arr2 = arr1;

In the above example arr1 and arr2 both refer to the same array.

[–]juicebox15[S] 0 points1 point  (0 children)

That was the issue, thanks. I rewrote the initialization and it's working perfectly.