The analyzer has detected a possible error in two or more nested for loops, when the counter of one of the loops is not used because of a typo.
The example:
let sum = 0;
for (let i = 0; i < N; i++) {
for (let j = 0; j < M; j++) {
sum += matrix[i][i]; // <=
}
}
In this case, it is intended to process all elements of a matrix and sum up them, but i is used instead of j when indexing the columns.
The fixed code:
let sum = 0;
for (let i = 0; i < N; i++) {
for (let j = 0; j < M; j++) {
sum += matrix[i][j];
}
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: