JavaScript, React, Programming, Web Development, Front End Development.
be 4,4,4,4 because once the the loop ends the value of i will be 4 and because we are using var to declare the variable, its value is captured by all instances of setTimeout and at last 4,4,4,4 will be printed. . Can you fix the code so that it prints 0,1,2,3 . . Here I am giving two ways to fix