JS Utils Kit - v0.5.1
    Preparing search index...

    Function shortestWordLength

    • Finds the length of the shortest word in a string.

      Parameters

      • str: string

        The input string.

      Returns number

      Length of the shortest word.

      • Words are split by whitespace (/\s+/).
      • Symbols (punctuation, special chars) are removed using stripSymbols.
      • Returns 0 if the string is empty or contains no words.
      shortestWordLength("js utils kit"); // 2
      shortestWordLength("one three five"); // 3
      shortestWordLength(""); // 0