Question: Step 5 : Create a function with closure Write a function outerFunction that declares a local variable and returns an inner function. The inner function

Step 5: Create a function with closure
Write a function outerFunction that declares a local variable and returns an inner function. The inner function should update the local variable each time it's called.
Hint:
Closures allow the inner function to remember the local variables of the outer function even after the outer function is done.
Snippet:
function outerFunction(){ let count =0; return function(){// update count here }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!