Created
          November 25, 2023 04:59 
        
      - 
      
- 
        Save kenneropia/aed1b37f6271b1b4ab0e3271fd761518 to your computer and use it in GitHub Desktop. 
Revisions
- 
        kenneropia created this gist Nov 25, 2023 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ const mergeWord = (word1: string, word2: string) => { let shorterWord = '' let longerWord = '' let accu = '' if (word1.length < word2.length) { shorterWord = word1 longerWord = word2 } else if (word2.length < word1.length) { shorterWord = word2 longerWord = word1 } else { shorterWord = word1 longerWord = word2 } for (let i = 0; i < shorterWord.length; i++) { const element = shorterWord[i]; accu += element if (longerWord[i]) { accu += longerWord[i] } } accu += longerWord.substring(shorterWord.length, longerWord.length) return accu } const result = mergeWord("abcDc", "pqrkja") console.log(result)