Reverse Words in a String III

EasyTwo PointersString

Solution

export function reverseWords(s: string): string {
  const BLANK = '';
  const SPACE = ' ';
  const reverseWord = (word: string) => [...word].reverse().join(BLANK);
  return s.split(SPACE).map(reverseWord).join(SPACE);
}