+ 1
Can anyone explain it please? And give an answer.
var count=0; for(i=0,i<3 ;i++) { for(j=3;j>0;j--){ ++count;}} alert(++count) ;
5 Réponses
+ 18
Infinite loop... ~_~
+ 5
Are you sure of the code?
Because actually the nested loop (the one with 'j' counter) is an infinite one, as j is incremented so will never be less or equal to zero, and alert() will never be executed ^^
+ 4
By the way, i assume you meant to write "j--" in the for loop, or else you enter an infinite loop
+ 1
10
The ++ before the variable first adds 1 to it, then use it for your purpose.. You nested 2 for loops, every each runs 3 times => 9 increments to the variable 'count'. Finally, you alert ++count, which means you first add 1 to it and only then alert it, so practically you alert 10
+ 1
Sorry friends.. I have corrected the question now... You were right @tzahi leh... I meant j--