Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //03.Merge Arrays
- function mergeArrays(arr1, arr2) {
- 'use strict'
- let thirdArr = []
- let output = ''
- for (let i = 0; i < arr1.length; i++) {
- if (i % 2 === 0)
- thirdArr[i] = +arr1[i] + +arr2[i]
- else
- thirdArr[i] = arr1[i] + arr2[i]
- if (i === arr1.length - 1)
- output += `${thirdArr[i]}`
- else
- output += `${thirdArr[i]} - `
- }
- console.log(output)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement