Tell us what’s happening:
The first one passed the test but the second one not at all.
Your code so far
function frankenSplice(arr1, arr2, n) {
let myArray = arr2.slice(0);
myArray.splice(n, 0, ...arr1);
return myArray;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1)); //-->4, 1, 2, 3, 5
function frankenSplice(arr1, arr2, n) {
let array2Copy = arr2.slice(0);
for (let i = 0; i < arr1.length; i++){
array2Copy.splice(n, 0, arr1[i]);
}
return array2Copy;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1)); //-->4,3,2,1,5
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.94
.
Link to the challenge: