Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Value is getting undefined after passing it to other argument

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you need to pass radioValue to function, addHandleToChange(radioValue);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!