Looking for help with a for in loop I am using in which returns undefined at the the end.
I have 26 buttons, one button for each letter in the alphabet. I need to scan
You should not use a for-in loop over a collection. If you do you need to test hasOwnProperty
Instead use a simple loop
var item = document.getElementsByClassName('button');
// or better: var item = document.querySelectorAll('.button');
for (var i=0;i
var item = document.getElementsByClassName('button');
// or better: var item = document.querySelectorAll('.button');
for (var i = 0; i < item.length; i++) {
item[i].onclick = function() {
console.log(this.value);
};
}
Game