Created
April 30, 2019 23:17
-
-
Save alvarezgarcia/c6b76fcb015e18c1543a26364b6d5e17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstList = [1, 2, 3, 5, 9, 10, 13, 16, 28]; | |
const secondList = [5, 6, 7, 8, 11, 42, 11]; | |
const maxLength = firstList.length > secondList.length ? firstList.length : secondList.length; | |
let finalList = []; | |
for (let k = 0; k < maxLength; k++) { | |
if (!firstList[k]) { | |
finalList.push(secondList[k]); | |
} else if (!secondList[k]) { | |
finalList.push(firstList[k]); | |
} else { | |
finalList.push(firstList[k], secondList[k]); | |
} | |
} | |
console.log(finalList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment