Tell us what’s happening:
Could anyone explain what does this means?
Hint 2
Loop through all of the items in the first array. For each item in the first array splice it into the copied array in the index given as argument.
Hint 3
Increment the index after performing the splice.
Advice, please
Your code so far
function frankenSplice(arr1, arr2, n) {
let newArray = arr2.slice() //1. Copy all the items of arr1 into the second arrary arr2, this also make sure that they are not mutated
for(let i= 0; i <= arr1.length; i++) { // 2. Loop through all of the items in the first array.
arr1[1] = newArray.splice()
//How to increment the index after performing the splice??
}
return newArray;
}
console.log(frankenSplice([1, 2, 3], [4, 5,], 1));
function frankenSplice(arr1, arr2, n) {
return arr2;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
.
Challenge: Slice and Splice
Link to the challenge: