0
Can anyone please tell me why it's answer is 04
for(i=0;i<=5;i++){ i += i; console.log(i); i++; }
4 Respuestas
+ 6
First iteration ( i = 0 )
i += i; // still 0
i++; // becomes 1
i++ // becomes 2 ( in loop construct )
Second iteration ( i = 2 )
i += i; // becomes 4
i++; // becomes 5
i++ // becomes 6 ( in loop construct )
Loop cease repetition cause <i> is now 6, which means the condition i <= 5 no longer satisfy.
+ 3
console.log() prints its argument in separate line. I got the below result in JS console
0
4
+ 1
then why my console is showing 0 4 output
0
First iteration:
i=0;
Print 0
Second interaction:
i=1
i++=2
i+=i Print 4