Maximum Number of Words Found in Sentences

EasyArrayString

Solution

export function mostWordsFound(sentences: string[]): number {
  function countWord(sentence: string) {
    return sentence.split(' ').length;
  }
  return sentences.reduce((wordCount, sentence) => Math.max(wordCount, countWord(sentence)), 0);
}