I understand that this code is not suitable, but it also works, is it possible to make a few correct options, and not so that it is according to the developer’s code???
Here, you can confirm that it doesn’t pass the first test with the following code:
// your function definition
function frankenSplice(arr1, arr2, n) {
for (let i = 0; i < arr1.length; i++) {
n = arr1[i];
arr1[i] = arr2[i];
arr2[i] = n;
}
return arr2;
}
// log the return value
const result = frankenSplice([1, 2, 3], [4, 5], 1);
console.log(result);
Here’s what it logs to the console
[ 1, 2, 3 ]
That is not equal to [4, 1, 2, 3, 5] which is what the test expects.