NovichokJS,
const createArrOfFunc = (number = 0) => {
if (typeof number !== 'number') { return null; }
let arr = [];
for (let i = 0; i < number; i += 1) {
function func() {
return i;
};
arr.push(func);
}
return arr;
}
console.log(createArrOfFunc(9)[5]());
console.log(createArrOfFunc());
console.log(createArrOfFunc('test'));