Hello, can anyone tell me why my solution hasn’t been accepted?
function frankenSplice(arr1, arr2, n) {
let array2 = arr2.slice(0);
array2.splice(n, 0, arr1);
return array2;
}
Hello, can anyone tell me why my solution hasn’t been accepted?
function frankenSplice(arr1, arr2, n) {
let array2 = arr2.slice(0);
array2.splice(n, 0, arr1);
return array2;
}
You’re splicing a copy of arr1 (as in the actual array) into arr2, not the values from arr1.
you’re doing
> frankenSplice([1], [2, 3], 1)
[1, [2, 3]]
when it should be
> frankenSplice([1], [2, 3], 1)
[1, 2, 3]
(note the console output just shows the values in the arrays, it doesn’t show the structure of the arrays)
Thank you man. It was really helpful.