Tell us what’s happening:
Can anyone help me return the value of someSplice as stated in my code. I don’t have any idea why it doesn’t return the value.
Your code so far
function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
let someSlice = arr1.slice(0, arr1.length);
let someSplice = arr2.splice(n, 0, ...someSlice);
return someSplice;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
The only problem I had is The second array should remain the same after the function runs. as stated by FCC challenge.
This code works but I need a way to not change arr2.
function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
let someSlice = arr1.slice(0, arr1.length);
arr2.splice(n, 0, ...someSlice);
return arr2;
}
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/66.0.3359.181 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice