+ 2
Why this code give output as 6?? Solved
let x=0; for(let i=0;i<4;i++){ x=x+i;} console.log(x)
5 Antworten
+ 3
when i = 0, x = 0
i=1, x = 1
i=2, x = 3 (1 +2) // previous x and current i values
i=3, x = 6 ( 3+3) // pre x = 3, current i = 3
so, 6 is the final answer
what were you hoping to get?
+ 1
Now i understood....
+ 1
Thanks bruhh!
0
close the case👍
0
edit your question and write [ Solved ] in front of it