1768. Merge Strings Alternately
202408241425
tags: #string
var mergeAlternately = function(word1, word2) {
const res = [];
for (let i = 0; i < Math.min(word1.length, word2.length); i++) {
res.push(word1[i] + word2[i]);
}
res.push(word1.length > word2.length ? word1.slice(word2.length) : word2.slice(word1.length));
return res.join('');
};