0
var buttons = document.querySelectorAll('.drum');

for (let i = 0; i < buttons.length; i++) {
  buttons[i].addEventListener('click', () => {
    playSound(buttons[i].innerHTML);
  });
}

Can someone please explain to me why I can't use this.innerHTML to reference to my button?

Thanks!

  • 2
    A `=>` function will not get its own local `this` value. – Pointy Jul 20 '22 at 12:25
  • 1
    Does this answer your question? https://stackoverflow.com/questions/28798330/arrow-functions-and-this – evolutionxbox Jul 20 '22 at 12:26
  • Duplicate of [What does arrow function '() => {}' mean in Javascript?](https://stackoverflow.com/questions/29030747/what-does-arrow-function-mean-in-javascript) – esqew Jul 20 '22 at 12:27

0 Answers0