Skip to content

Instantly share code, notes, and snippets.

@oliverjam
Created November 24, 2016 13:36
Show Gist options
  • Save oliverjam/1bdd8c42266673b935a23b1a503bdbb7 to your computer and use it in GitHub Desktop.
Save oliverjam/1bdd8c42266673b935a23b1a503bdbb7 to your computer and use it in GitHub Desktop.
Interlace Arbitrary Strings created by oliverjam - https://repl.it/E7Hk/1
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