I try to understand nested for loops in javascript but it's very confusing.
I have this code and I can't understand how it works:
let n = 5;
for (let i = 0; i < n; i++) {
for (let j = 0; j < i; j++) {
console.log(j);
}}
In console I have : 0 1 0 1 2 0 1 2 3
And I'm trying to figure out which loop represent each number.
i
in the log also and it will probably help you visualize better – charlietfl