Hi all - I had the right code except for the spread operator in the splice call (…arr1) and I was trying a dozen different ways to include the first array values only and not as a subarray. Why does the spread operator make that happen?
function frankenSplice(arr1, arr2, n) {
let newArr = arr2.slice();
newArr.splice(n, 0, arr1);
return newArr;
}
console.log(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36.
Challenge: Slice and Splice
Link to the challenge: