Tell us what’s happening:
Hello there, I’m currently trying to complete this challenge, and I’m so close, but it says that I shouldn’t modify arr2. I don’t see where I’m modifying it in the code? Please help, thanks
Your code so far
function frankenSplice(arr1, arr2, n) {
const localArr = arr2
localArr.splice(n,0,...arr1)
return localArr
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Basic Algorithm Scripting - Slice and Splice
ILM
April 29, 2025, 5:54pm
2
chetanzeogu410:
const localArr = arr2
what do you think this does?
stores the 2nd array in the localArr
variable
ILM
April 29, 2025, 8:13pm
4
that’s true, but more specifically, what is it doing with the array? new array, same array… ?
I think it’s the same array.
ILM
April 29, 2025, 8:21pm
6
so if it’s the same array, do you know see where you are changing arr2
?
Uh do you mean do I know where I’m changing the array?
ILM
April 29, 2025, 8:23pm
8
yea, you said it’s the same array
1 Like
I’m changing the array in the second line I think.
ILM
April 29, 2025, 8:25pm
10
so that’s where you are changing arr2
Yeah, cuz I’m using the splice
method on the localArr
ILM
April 29, 2025, 8:26pm
12
I executed the function, it doesn’t really make sense .
ILM
April 29, 2025, 8:28pm
14
what does not make sense?
ILM
April 29, 2025, 8:30pm
16
can you add some more of what not makes sense? it shows what happens
Why does it say localArr not defined
ILM
April 29, 2025, 8:31pm
18
it is not defined before the line in which it is defined is executed, continue with the execution to see what happens
2 Likes
It seems to give the right output when it’s finished
ILM
April 29, 2025, 8:34pm
20
yes, but your issue wasn’t with the output, was it?