tzi0

Concat arrays

Sep 11th, 2020 (edited)
793
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let arrIds = ["id0", "id1", "id2", "id3", "id4", "id5"];
  2. let arrValues = [1,2,3,4,5,6,7,8,9,10];
  3.  
  4. function concatArrays(ar1, ar2) {
  5.     return ar1.map(item => {
  6.         return [item].concat(ar2);
  7.     }).flat()
  8. }
  9.  
  10. console.log(concatArrays(arrIds, arrValues));
RAW Paste Data