0

Having problems understanding nested for loops please help. Why is this code producing 12

var b =0; for( var i = 0; i<=2 ; i++) { for(var j =0; j<=3; j++) { b++; } }

19th Jun 2021, 1:17 PM
Allan 🔥STORMER🔥🔥🔥🔥
Allan 🔥STORMER🔥🔥🔥🔥 - avatar
1 Antwort
+ 8
For every iteration of the outer loop, the inner loop runs 4 times from 0 to 3. So the outer loop runs 3 times from 0 to 2. So 4*3=12.
19th Jun 2021, 1:26 PM
Avinesh
Avinesh - avatar