Tell us what’s happening:
What am I missing here? I seem to be returning what the problem is asking me to return. Is a loop really the only option here?
Your code so far
function frankenSplice(arr1, arr2, n) {
let newArray1 = arr1.slice();
//console.log(newArray1);
let newArray2 = arr2.slice();
//console.log(newArray2);
newArray2.splice(n, 0, newArray1);
return newArray2;
}
console.log(frankenSplice([1,2,3], [4,5], 1));
console.log(frankenSplice([1,2], ["a", "b"], 1));
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.14; rv:65.0) Gecko/20100101 Firefox/65.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice/