+ 2
Explain Output
for (let i = 0; i < 5; i++){ i += i; document.write(i); i++; } Output for this code is 04. Please explain me the logic.
1 ответ
+ 7
first for loop: i = 0
i += i; similar to i = i + i; so i = 0 + 0 thus i = 0
document.write(0)
i++ means inkrement 1 so i = i + 1 thus after i = 1
second for loop: to i will be added 1 thus now i = 1+1 = 2
i += i as above i = 2 + 2 = 4
document.write(4)
i++ means i = i+1 = 4 +1 = 5
i is not more smaller (<) than 5 that means END of the for loop.