+ 8
Why output in this code is 01234 ???
Why output is 01234. My answer was 44444 Because variable "i" is displayed. https://code.sololearn.com/WPCXr1s7oC24/?ref=app Plesae explain
6 Respuestas
+ 6
You have j and i
j --> from 0 to 4 (because of j++)
i = 4
line 6:
(j) --> 01234
(i) --> 44444
+ 5
Because the i that you give to the function dosnt gets incrememtet. Just the i outside the function.
What out for the different scopes.
+ 4
Kaamil Kyeremeah Please don't spam.
https://www.sololearn.com/discuss/1316935/?ref=app
0
Your code can be simplified with
for (var j=0,i=4; i<5; i++) (function(_i) {console.log(_i);})(j) --> answer 01234
Replace with
for (var j=0,i=4; i<5; i++) (function(_i) {console.log(i);})(j) --> answer 44444
to get the answer you thought
Your
0
Hi
- 1
Hello era you