+ 7
Why it is not 0 1 2 3 4 5?
Why not 0 1 2 3 4 5 https://code.sololearn.com/W9NpIZA4ftt8/?ref=app
5 Réponses
+ 4
Because i is getting incrementet so fast that after the waiting time of 1000*i miliseconds i has the value 6.
And so it only prints 6.
+ 2
1 It is post increment. var i
2 The timeout never occurred
3 The Max of var i is 5
4 I++ = 6
5 loop prints 6 six times 🤗
+ 1
U may need async and await
0
Trying to understand this..
In part A of the code, the values are logged as expected but can't see the time delay..
In part B, there is overall delay of 5 sec but prints values correctly in for loop not when called using set timeout function..
Also why the behaviour changes when the function takes parameter/argument..
https://code.sololearn.com/WX6GVnTf5odf/?ref=app