New to JavaScript? You’re going to face this issue if not already
Adding click event listeners in a loop can be a mystery
Published in
6 min readFeb 18, 2020
When you attach multiple click events to elements such as buttons inside a for loop, the click event will always give us the last index value regardless of what button is pressed.