jsartisan / frontend-challenges

FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
https://frontend-challenges.com
20 stars 3 forks source link

99 - Closure 2 - javascript #102

Open jsartisan opened 6 days ago

jsartisan commented 6 days ago

index.js

export function createFunctions() {
  const functions = [];

  for (let i = 0; i < 10; i++) {
    let func = function () {
      console.log(i);
    };

    functions.push(func);
  }

  return functions;
}