Oh yeah. I don’t think i’m modifying arr2
here when you said “I think it’s the same array”, you did not meant that, right? you were thinking that it is a copy
because if arr2
is the same array as localCopy
when you change localCopy
you are also changing arr2
what does the visualizer show?
it looks like it’s the same array
Oh. How would I create a new copy then?
well, this is a thing that people have to hit their head on
if you want to research the topic, it’s “pass by value vs pass by reference”
for how to copy an array, that will have to be your next research
2 Likes
.slice()
worked, thank you