+ 3
Can someone ,please help better explain this code to me in JavaScript
var i,j; var c=0; for(i=1; i<=3; i++){ for(j=1,j<=2; j++){ c+=j; } } alert(c) output //9 how ,can someone help out here ,to better explain this loop
3 Respuestas
+ 1
The inner loop adds 3 to c:
c+= 1 // c === 1
c+= 2 // c === 3
The outer loop repeats the inner loop 3 times, hence 3 * 3 = 9.
+ 2
thank a lot Nguyen Van Hoang
0
You're welcome. Glad to help.