My goal is to create an array of arrays in JavaScript, with each inner array filled with the value false
. However, I'm encountering an error message that says:
Uncaught TypeError: Cannot read property 'push' of undefined
The code I am currently using is as follows:
var fieldFilled = [];
for (var i = 0; i < 10; i++) {
fieldFilled.push([]);
for (var j = 0; j < 10; j++) {
fieldFilled[j].push(false);
}
}
I find it confusing because it appears that fieldFilled
is defined. Any insights or assistance on this issue would be greatly appreciated.
Thank you for your guidance.