so i have a homework problem need to solve . The requirement is just fix the code so console show true
var x = 2,
fns = [];
(function () {
var x = 5;
for (var i = 0; i < x; i++) {
// write here
}
})();
// DO NOT MODIFY BELOW CODE
console.log(x * 2===fns[x * 2]());
// console must show true
the console output is
Uncaught TypeError: fns[(x * 2)] is not a function
I try to rewrite function as it one of element in array but console still show error.
I rewrite the fns[x * 2]()
to fns[x * 2]
and the console show return false (which is fine cause at least it not throw error ) but cant modify it according to the requirement