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

218
Views
How to merge two subarrays in JavaScript without changing the order of the array

I need to merge two subarrays inside an array without pushing them to the end of the array

let array = [["a"], ["b"], ["c"], ["d"]];
array[1] = array[1].concat[2];

So I basically want array to be

array = [["a"], ["bc"], ["d"]];

Thanks!

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

0

You could splice the array and remove the item for adding to another item.

let array = [["a"], ["b"], ["c"], ["d"]];

array[1][0] += array.splice(2, 1).join('');

console.log(array);

about 4 years ago · Juan Pablo Isaza Report

0

const arr = [['a'], ['b'], ['c'], ['d']];

arr[1][0] += arr[2][0];
arr.splice(2, 1);
console.log(arr);
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!