Slice and Splice...HELP

Slice and Splice...HELP
0

#1

Tell us what’s happening:
Hi I am back I want to tell me where is the wrong.Can you explain me where is my wrong?

Your code so far


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/68.0.3440.84 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice


#2

Are you supposed to use splice here?


#4

I don’t know.Can you explain me


#5

Splice mutates the original array. Mutates means changes. Do you want the original arrays to be changed or not?


#6

I belive no but I don’y know


#7

Instructions say that you want arr1 and arr2 to be unchanged, so yes, you are correct to believe no.

So if you can’t use splice, you’ll have to use some other way of making Frankenarray.


#8

my exercise tell me that The second array should remain the same after the function runs.And this is wrong.


#9

The test is not wrong. You’ve changed arr2.


#10

Create 2 new variables that are copies of the original arrays, then use those within the function. This will keep the originals the same and allow you to use mutating methods.


#11

You only need to make a copy of one of the arrays to solve this challenge.


#12

Yes you are right. I may have a problem with reading instructions.


#13

Happens to all of us.

edit: I’d like to add that your suggestion doesn’t really violate the instructions at all.