Function joinWithFinalConjunction

  • Join elements into a string with commas separating each value. Add a conjunction before the final item in the list. If the array has a length < 2, the conjunction is not added. If the list is only of length 2, then no commas are added.

    Parameters

    • list: readonly any[]

      Array of items to be converted into strings. Works best if these are simply strings to begin with.

    • conjunction: string = 'and'

      The conjunction to be used before the final element.

      'and'
      

    Returns string