ts-playground
    Preparing search index...

    Function wordCount

    • Count the number of words in the documents

      Parameters

      • documents: Document[]

        The documents to count words from (array of arrays of words)

      Returns WordScore

      A dictionary of words and their counts

      const documents = [
      ['a', 'b', 'c'],
      ['a', 'b', 'd'],
      ]
      const result = wordCount(documents)
      result // => { a: 2, b: 2, c: 1, d: 1 }