Function parameterise

  • Replaces spaces in a word with a hyphen or custom separator character so that the word may be used as part of friendly URL slug.

    Parameters

    • word: string

      a word to have spaces replaced by a separator.

    • separator: string = '-'

      a separator character to replace spaces with.

    • preserveCase: boolean = false

      if set to true, the word will not be made lower case.

    Returns string

    a copy of the word seperated by hyphens or a custom separator.