Welcome to the forum!
Your error comes from the fact that you are assigning
stage1 to the variable
fase before the variable
stage1 has been initialized.
This is what happens :
stage1 variable so it’s doing :
var stage1; // Uninitialized -> undefined
- Then we declare and assign
fase which is
var fase = stage1; // -> undefined
stage1 variable gets initialized with the array :
var stage1 = [
[‘0’, ‘1’, ‘0’, ‘1’],
[‘0’, ‘1’, ‘1’, ‘0’],
fase is still undefined!!
Check out this simple example :
var a = b;
console.log(a); // Prints undefined
var b = [0, 1];
console.log(a, b); // Prints undefined [0, 1]
So you need to assign
stage1 has been initialized