function longest(s1, s2) { const totalString = (s1+s2).split('').sort() for (let i=0; i < totalString.length; i++) { while(totalString[i] === totalString[i+1]) totalString.splice(i+1, 1) } return totalString.join('') }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter