Not the correct index
by colintoh
JavaScript
var room = [];
function setupRoom(){
for(var i = 0; i < 5; i++){
(function(j){
room.push(function(){
return "I'm furniture number " + j;
});
})(i)
}
}
setupRoom();
console.log(room[0]()); // Expected result: I'm furniture number 0
console.log(room[3]()); // Expected result: I'm furniture number 3