Nested loops allow you to run a loop inside another loop. This is especially useful when working with multidimensional arrays, combinations of values, or matrix-style problems. Where conventionally you use i as a temporary variable in a loop, you would use j as a temporary variable for the nested loop.
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 2; j++) {
console.log(`i = ${i}, j = ${j}`);
}
}
// This will print all combinations of i and j:
// i = 0, j = 0
// i = 0, j = 1
// i = 1, j = 0