Tell us what’s happening:
Below is my code. I suspect my problem is with how I am assigning the variable newArray and writing the loop code. Any feedback would be appreciated.
Your code so far
function frankenSplice(arr1, arr2, n) {
var array2 = arr2.slice(0);
var array1 = arr1.slice(0);
var newArray =
for (var i = 0; i < array1.length; i++) {
array2.splice(n, 0, array1[i]);
}
return newArray;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge: Slice and Splice
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice