JSFiddle - React, Tailwind, and code Playground JavaScript var s = "DCAB"; s = s.split('').sort().join(''); var split = s.split("", 2) alert(split);