I'm trying to make an array to tidy up my code so that I can add a bunch of event listeners to various buttons.
for(var i = 0; i < buttoncount; i++){
var targetid = document.getElementsByTagName("button")[i].id;
var targetidfunc = targetid + "function";
console.log(targetidfunc);
document.getElementById(targetid).addEventListener("click", targetidfunc);
}
The console has the correct function names however the event listener does not work, how can I fix this?