Hi, after looking into splice and slice it seems this should work but it’s not. The hint is also asking to splice and loop, but I’m not sure why i’d need to use slice to “create a copy of the second array inside of function” etc.
Your code so far
function frankenSplice(arr1, arr2, n) {
return arr2.splice(n, 0, arr1); // start at index n, doesn't delete anything, pushes in arr1
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1));
// copy arr1 to arr2 in order starting at index of n
// return result of the above
// slice = which indexes to delete (1,3) = 2
// splice = remove/replace and or add new element (index, how many to delete, new element)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36
.
Challenge: Slice and Splice
Link to the challenge: