• Category

    Adds all the elements of an iterable into a string, separated by the specified separator string.

    Time complexity: O(n)

    Space complexity: O(n)

    Parameters

    • iterable: Iterable<unknown>

      The iterable to join

    • separator: string = ','

      A string used to separate one element of the iterable from the next in the resulting string

    Returns string

    A string containing the elements in iterable joined by separator

    Iterable

    join(['a', 'b', 'c']); // 'a,b,c'
    
    join(['a', 'b', 'c'], '-'); // 'a-b-c'