Junior — Senior
What will be output to the console (example 42)
livecode
Task condition
You need to understand what output will appear in the console after executing the following JavaScript code:
var i = 10;
var array = [];
while (i--) {
array.push(function() {
return i + 1;
});
}
console.log([
array[0](), // ???
array[1](), // ???
]);
}
Determine the values that the calls array[0]() and array[1]() will return.