function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let newArray="";
newArray=arr2.slice();
for (let i = 0; i < arr1.length; i++) {
newArray.splice(n, 0, arr1[i]);
n++;
}
return newArray;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1));
this code give frankenSplice([1, 2, 3], [4, 5], 1)
should return [4, 1, 2, 3, 5]
. this result
But
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let newArray="";
newArray=arr2.slice();
newArray.splice(n,0,arr1);
return newArray;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1));
this code give frankenSplice([1, 2, 3], [4, 5], 1)
should return [4, 1, 2, 3, 5]
. this result as well. Now my question why the last solution is not accepted as an answer. where is the problem? can anyone help me, please?