Function permutations

  • Get all permutations of an array

    Parameters

    • arr: any[]

    Returns any[]

    an array 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"]
    ]