Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mergeArray(firstArray, secondArray) {
- let newArray = new Array(firstArray.length).fill(0);
- for (let index = 0; index < firstArray.length; index++) {
- if (index % 2 === 0) {
- newArray[index] = Number(firstArray[index]) + Number(secondArray[index]);
- } else {
- newArray[index] = firstArray[index] + secondArray[index];
- }
- }
- console.log(newArray.join(' - '));
- }
Advertisement
Add Comment
Please, Sign In to add comment