Nested Loops

Hello Guys,

While I understand codecademy’s explanation of loops and nested loops, there is something I find confusing. Please click the link below and explain when to use the outer loop and the inner loop in the if statement.

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-learn-javascript-syntax-loops/lessons/loops/exercises/for-loops-iii

The inner loop is used in their example while the outer look is used in the exercise. I would like to know why the diference.

The purpose of nesting is to be able to pair up all the permutations possible between the two arrays.

a = [10, 20, 30]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for (i of a) {
    for (j of b) {
        console.log(`(${i}, ${j})`)
    }
}
(10, 1)
(10, 2)
(10, 3)
(10, 4)
(10, 5)
(10, 6)
(10, 7)
(10, 8)
(10, 9)
(20, 1)
(20, 2)
(20, 3)
(20, 4)
(20, 5)
(20, 6)
(20, 7)
(20, 8)
(20, 9)
(30, 1)
(30, 2)
(30, 3)
(30, 4)
(30, 5)
(30, 6)
(30, 7)
(30, 8)
(30, 9)

Can you show us the two examples (the code, that is)?