Help needed with populating a binary matrix.
let binaryMatrix: number[][] = [];
for (let i = 0; i < 7; i++) {
for (let j = 0; j < 7; j++) {
if (!binaryMatrix[i]) binaryMatrix[i] = [];
if (!binaryMatrix[i][j]) binaryMatrix[i][j] = []; // triggering TS exception
binaryMatrix[i][j] = 1;
}
}
The statement binaryMatrix[i][j] = []
causes a TS exception -
Type 'never[]' is not assignable to type 'number'.ts(2322)
.
Any suggestions on how to resolve this issue?