7 Replies
that's not how unshift works. Unshift puts the arguments into the array, and you're feeding it two arrays, which puts each array (not the elements in the array, but the array itself) into the finalArr
i tried to do this finalArr = [arrOne,arrTwo]
and the same result happend
that's the same thing, yeah
you need to use the spread operator in this case
that puts all the elements into the new array rather than the array itself into a nested array
OHHHHHHHHHHHHH MYYYYYYYYYY GOOOOOOOOOOOOOOOOD
IT WORKED
IS THAT A CHEAT CODE
It's just a language feature
there is also concat() method 🙂
and there's a mix of both:
.unshift(...array2)