Closures in JavaScript | Inside a loop, inner function and setTimeoout