Question: What is output of below code? function create Counter(){ let i = 0 return function(){ i++ return i } } let increase1 = createCounter()


What is output of below code? function create Counter(){ let i = 

What is output of below code? function create Counter(){ let i = 0 return function(){ i++ return i } } let increase1 = createCounter() let increase2 = createCounter() console.log(increase1()) console.log(increase1()) console.log(increase2()) console.log(increase2())

Step by Step Solution

3.35 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 2 1 This is because each time the createCounter func... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!