/** * @param {string}word1 * @param {string}word2 * @return {string} */ var mergeAlternately = function (word1, word2) { let i; let res = ""; for (i = 0; i < word1.length && i < word2.length; i++) { res += word1[i] + word2[i]; } if (i < word1.length) res += word1.slice(i); if (i < word2.length) res += word2.slice(i); return res; };