Advertisement
BoyanGyurov

Untitled

Jan 28th, 2022
824
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function mergeArr(arr1, arr2) {
  2.     let newArr = [];
  3.  
  4.     for (let i = 0; i < arr1.length; i++) {
  5.         if (i % 2 == 0) {
  6.             newArr.push(Number(arr1[i]) + Number(arr2[i]));
  7.         } else {
  8.             newArr.push(arr1[i] + arr2[i]);
  9.         }
  10.  
  11.  
  12.     }
  13.     console.log(newArr.join(" - "));
  14.  
  15. }
  16. mergeArr(['5', '15', '23', '56', '35'], ['17', '22', '87', '36', '11'])
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement