## Question:

Hello im a newbie in learning javascript. May I know how the code works line by line? My answer is 12121212 but modal answer is 111222333444.

To my understanding, the inner loop must run finish first. The outer loop will be the number of times the loop will run. So, when i = 1 (first loop), j = 1, then since it ++, it will become 2 but not 3 since its j<3.

After that loop number 2, will print out j = 1 and 2 again This continues until the 4th loop ends.

## Answer:

The concept behind your code is nested looping. So you need to multiply the count of each loops to get the total number of loops happening in the code. In your casefor(i=1;i<5;i++) runs 4 times i=1,2,3,4 for(j=0;i<3;j++) runs 3 times j=0,1,2

Here, It is 3*4 = 12 times

When it enters the first loop(i.e., i). The loop inside it runs 3 times. Since you are printing i, For the first loop, It would be 111. And then for the second loop. It would be 222 and So on.

You would understand better If you write like below,

If you have better answer, please add a comment about this, thank you!