Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69f35a5bb823ed620fcb7cbc Challenge 283: String Zipper 28 challenge-283

--description--

Given two strings, return a new string that interleaves their characters one at a time. If one string is longer, append the remaining characters at the end.

Begin with the first character of the first string.

--hints--

zipStrings("abc", "123") should return "a1b2c3".

assert.equal(zipStrings("abc", "123"), "a1b2c3");

zipStrings("acegikmoqsuwy", "bdfhjlnprtvxz") should return "abcdefghijklmnopqrstuvwxyz".

assert.equal(zipStrings("acegikmoqsuwy", "bdfhjlnprtvxz"), "abcdefghijklmnopqrstuvwxyz");

zipStrings("day", "night") should return "dnaiyght".

assert.equal(zipStrings("day", "night"), "dnaiyght");

zipStrings("python", "javascript") should return "pjyatvhaosncript".

assert.equal(zipStrings("python", "javascript"), "pjyatvhaosncript");

zipStrings("feCdCm", "reoeap") should return "freeCodeCamp".

assert.equal(zipStrings("feCdCm", "reoeap"), "freeCodeCamp");

--seed--

--seed-contents--

function zipStrings(a, b) {

  return a;
}

--solutions--

function zipStrings(a, b) {
  let result = '';
  const len = Math.max(a.length, b.length);
  for (let i = 0; i < len; i++) {
    if (i < a.length) result += a[i];
    if (i < b.length) result += b[i];
  }
  return result;
}