Created
November 24, 2016 13:36
-
-
Save oliverjam/1bdd8c42266673b935a23b1a503bdbb7 to your computer and use it in GitHub Desktop.
Interlace Arbitrary Strings created by oliverjam - https://repl.it/E7Hk/1
This file contains hidden or 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 combineStrings() { | |
let result = ''; | |
if (arguments.length > 0) { | |
const args = [...arguments]; | |
const maxLength = args.map(item => item.length).reduce((a, b) => Math.max(a, b)); | |
for (let i = 0; i < maxLength; i++) { | |
args.forEach(item => { | |
result += item.charAt(i); | |
}); | |
} | |
} | |
return result; | |
} | |
combineStrings('abc', '123'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment