+ 1

Need clarification please.

var arr = []; for (i = 2; i > 0; i --) { arr [i] = i; } document.write(arr.length*i);

20th Feb 2018, 11:40 PM
Briaה‎
1 Réponse
+ 2
The answer will be 0. Since you didn't define 'i' as 'let', it is global. Therefore, at the end of the loop, 'i' will be zero and arr = [null,1,2].
21st Feb 2018, 2:31 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar