Nested Loops

Nested loops is also a possible feature. That means you can create a loop inside a loop. This is very useful when we want to make a repetitive task, and for each item of it we want to assign another repetitive task one more.

For example what if we want to find all customers of our web app that are coming from Iran and they were born after 1988 (are under 30 years old), those are two different properties. First we need to find those that are coming from Iran, so we need to loop through ALL customers, and every time we find someone coming from Iran, we also loop through all the other properties to find it's birthdate and if it's before 1988. There are also other ways to solve this problem (such as object properties) but until then we will stick to this.

Let's see a practical example.

L-10 Create a matrix table multiplication exercise

Create a script that shows all the multiplication tables from numbers from 1 to 10 (and all the results by multiplying each number with each number from 1 to 10). Example follows:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10

2, 4, 6, 8, 10, 12, 14,16, 18, 20,

3, 6, 9, 12, 15, 18, 21, 24, 27, 30

etc.

Estimated time: 20 Mins.