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

133
Views
Combine 2 arrays of different lengths and sort date

I have 2 arrays with different lengths

let daysArray = ['09-20', '09-21', '09-22', '09-23', '09-24', '09-25', '09-26']

let weekNameArray = ['Mi', 'Do', 'Fr', 'Sa + So', 'Mo', 'Di' ]

combined them with _.zipWith:

let weakDateArr = _.zipWith(weekNameArray, daysArray , function(first, second) {
          return first + " " + second  
        });

How I can combine them to get the next array:

['Mi 09-20', 'Do 09-21', 'Fr 09-22', 'Sa + So', 'Mo 09-25', 'Di 09-26']

'Sa + So' must be undated *

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

0

Hmm, not sure lodash has support for this out of box...

You could apply a simple custom solution using Array.map() and an index offset for the daysArray:

days_offset = 0;
let combined = weekNameArray.map( (name, index) => {
    if(name.length <= 2) {
    return name + ' ' + daysArray[ index - days_offset ];
  } else {
    days_offset += 1;
    return name;
  }
});
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!