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

292
Views
Passing multiple "key-value" pairs as a parameter to a JS function

I have a date range picker, and I want to pass the two dates (startDate, endDate) to handleFilterChange, which builds an filter object to save in session storage. Currently I try to call the function, giving parameters as two arrays, which obviously doesn't work. Calling the function twice also didn't work.

Is this thing even possible and if, then what would be a correct way to pass these two dates to this function?

handleFilterChange

const handleFilterChange = (value, title) => {
    clearPreviousResults();
    const newFilters = {
        ...filters,
        [title]: value,
    };

    saveFilterValue(newFilters, FILTERS_STORAGE_KEY);
    setFilters(newFilters)

date picker

const handleDateRangeChange = dates => {
    if (!dates || dates.length <= 1) {
        return;
    }
    handleFilterChange( ["startDate", "endDate"], [dates[0], dates[1]] );
    };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I am assuming you are trying to save an object in the LocalStorage or session. I would rather send the whole dates array to handleFilterChange function.

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!