Function permutations

  • Get all permutations of an collection

    Parameters

    • arr: any[]

    Returns any[]

    an collection with all the permutations

    Example

    permutations(["a", "b", "c"])) // =>
    [
    ["a", "b", "c"],
    ["b", "a", "c"],
    ["b", "c", "a"],
    ["a", "c", "b"],
    ["c", "a", "b"],
    ["c", "b", "a"]
    ]