Created
September 9, 2017 22:36
-
-
Save brettbartylla/b20b519745a302de7263b72677281cb9 to your computer and use it in GitHub Desktop.
Takes two arrays (obj1, obj3) and merges their values into a new array. The result is the values of obj1 and obj2 but in the order of every other one of their values Ex. a1b2c3
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
function merge(obj1, obj2){ | |
var obj3 = []; | |
for (var i= 0, len = obj1.length; i < len; i++) { | |
obj3.push(obj1[i]); | |
obj3.push(obj2[i]); | |
} | |
return obj3; | |
} | |
//calls merge function, removes commas using join, displays output | |
document.getElementById("answer").innerHTML = merge('abc', '123').join(''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment