Tweakr
    Preparing search index...

    Function truncateWords

    • Truncates a string to a specified number of words.

      Parameters

      • input: string

        The string to truncate.

      • wordLimit: number

        Maximum number of words to keep.

      Returns string

      The truncated string.

      truncateWords("The quick brown fox", 2); // "The quick"
      truncateWords("Hello world!", 5); // "Hello world!"

      1.2.0