1、代码
let mergeAlternately = function(word1, word2) {
const arr = [];
const result1 = word1.split("");
const result2 = word2.split("");
while (result1.length && result2.length) {
arr.push(result1.shift());
arr.push(result2.shift());
};
return [...arr, ...result1, ...result2].join("");
};
console.log(mergeAlternately("ace", "bdf"));
console.log(mergeAlternately("ace", "bdfghi"));
console.log(mergeAlternately("acegi", "bdfh"));
2、原文链接
CSDN-原文
3、演示

