+ 3
Could someone please explain?
I know the answer is 12 but I don’t understand why: var a=0; for (k=1; k<=2; k++) { for (i=0; i<=5; i++) {} a++; console.log (a); }
6 Respuestas
+ 3
The answer is 12 because you display the value of a variable each iteration so at first iteration a is 1 so it displays 1 on console then at the second iteration a is increased by 1 again so it displays 2 beside 1
+ 2
Thanks @turtleshell. So the second loop isn’t factored?
+ 2
The second loop is useless
+ 1
Why is that may I ask?
+ 1
Ahhh... so obvious. Thank you!
0
Theres nothing inside the loop’s brackets
for (i=0; i<=5; i++) {} <—