I have to create a function that creates a new array based on the previous two but without mutating them.
function reverse(arr1, arr2) {
const arr3 = [...arr2, ...arr1];
return arr3;
}
The problem is the following
const arr1 = [1, 2];
const arr2 = [3, 4];
reverse(arr1, arr2);
arr1.toEqual([1, 2]);
};
I can not apply toEqual at arr1, I do not know if it is disarmed when I pass it to the reverse function and apply the spread, but if so, how can I create the new arrangement based on the other two, being that these remain arrangements?