+ 1

Which the aswer for the next code? And why?

Domnell Ral: [0,1,2,3,4,5,6,7,8,9,10] .forEach( i=>{ setTimeout(() => { console.log(i) }, 10000 - (i * 1000)) })

21st May 2017, 11:24 PM
Domnell Enrique
Domnell Enrique - avatar
1 Resposta
+ 1
the wait time will be lesser for higher values of i. so logically, the answer should be 0 to 10 in reverse order i.e. 10 first and 0 last
28th May 2017, 8:16 PM
Gurpreet Singh
Gurpreet Singh - avatar