
I wrote this code to get all possible arrangements for an array containing 3 elements.
let a = ["A", "B", "C"];
let b = [];
function change(A) {
let x = [];
for (let i = 0; i < A.length; i++) {
x.push(A[i]);
}
for (let i = 0; i < x.length; i++) {
A[i] = x[i + 1];
...