I'm 6 weeks in to a html/css/javascript course and I need to build a movie filter using a switch statement. I'm stuck and I don't know what to do.
I wrote this code (could be complete garbage, don't blame the noob):
const radioButtons = document.querySelectorAll('[name="film-filter"]');
function addEventListeners() {
for (let counter = 0; counter < radioButtons.length; counter++) {
radioButtons[counter].addEventListener("change", event => {
const radioValue = event.target.value;
/* console.log(radioValue); */
addHandleToChange();
});
};
};
function addHandleToChange(radioValue) {
console.log(radioValue);
};
addEventListeners();
I'm trying to the pass the const radioValue to the second function, the addHandleToChange. In this function I want to create my switch statement so I can start filtering the big movie Javascript file they provided using the radioValue const. But the console keeps saying the radioValue is undefined. Functions have stupid names but I have to keep these names.
Hopefully my question kind of straight to the point. Thanks in advance!
you need to pass radioValue to function, addHandleToChange(radioValue);