Tell us what’s happening:
I am stuck at this challenge and would appreciate any advice! So far my code looks like this:
function frankenSplice(arr1, arr2, n) {
var arr3 = arr2.slice(0);
arr3.splice(n, 0, arr1);
return arr3;
}
when I run it on the console I can see that I am inserting the first array at the position n so I am not inserting each element separately. I’ve also tried to use a for loop and the code worked for strings since I changed the values with toString method but it still wouldn’t work for numbers.
Thanks so much!
Your code so far
function frankenSplice(arr1, arr2, n) {
var arr3 = arr2.slice(0);
arr3.splice(n, 0, arr1);
return arr3;
}
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/67.0.3396.87 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice