Im confused why this code works
for(let i=12;i<=80;i++){
let emjoi = document.querySelector(`#em${i}`);
emjoi.addEventListener("click",() => {
console.log(i);
result 12 13 14 15 16 17 18 19 20 21 right though to 80
});
}
but if i do it this way without using let it only gives me the end value at the end of the loop
for(i=12;i<=80;i++){
let emjoi = document.querySelector(`#em${i}`);
emjoi.addEventListener("click",() => {
console.log(i);
result 81
});
}