en.javascript.info/1-js/06-more-functions/03-closure/8-make-army/_js.view/solution.js
Ilya Kantor 20784e7f26 up
2017-02-19 01:41:36 +03:00

13 lines
233 B
JavaScript

function makeArmy() {
let shooters = [];
for(let i = 0; i < 10; i++) {
let shooter = function() { // shooter function
alert( i ); // should show its number
};
shooters.push(shooter);
}
return shooters;
}