Advertisement
Spocoman

03. Merge Arrays

Jan 22nd, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(first, second) {
  2.    
  3.     let third = [];
  4.    
  5.     for(let i = 0; i < first.length; i++) {
  6.         if (i % 2 === 1) {
  7.             third.push((first[i] + second[i]).toString());
  8.         } else {
  9.             third.push(Number(first[i]) + Number(second[i]));
  10.         }
  11.     }
  12.     console.log(third.join(" - "));
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement