Skip to content

Instantly share code, notes, and snippets.

@sergzak022
Created March 16, 2018 17:16
Show Gist options
  • Save sergzak022/2f5b179283d955dc18eea906b0b34a3a to your computer and use it in GitHub Desktop.
Save sergzak022/2f5b179283d955dc18eea906b0b34a3a to your computer and use it in GitHub Desktop.
Recursive implementation for zipStrings function
function zipStrings(str1, str2) {
if (str1[0] == null && str2[0] == null) {
return '';
}
let ch1 = str1[0];
let ch2 = str2[0];
let tail = zip(
str1.slice(1),
str2.slice(1),
);
return `${ch1 || ''}${ch2 || ''}${tail}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment