I am attempting to add an eventListener to each html element from a nodelist, and pass that same html element as an argument to the callback function. My code looks like so.
let programs = document.getElementsByClassName('program-name')
for (i = 0; i < programs.length; i++){
programs[i].addEventListener("click", () => testFunc(programs[i]))
}
function testFunc(program) {
console.log(program)
}
The problem is that I am expecting console.log(program)
to log an html element to the console, however all the log is undefined