Implement the Slice and Splice Algorithm - Implement the Slice and Splice Algorithm

Tell us what’s happening:

can you tell me why my console output is in reverse order?

Your code so far

function frankenSplice(array1,array2,index){
let copyArray1 = array1.slice();
  let copyArray2 = array2.slice();

  for(let i =0;i<copyArray1.length;i++){
copyArray2.splice(index,0,copyArray1[i])


  } 

return copyArray2

};
console.log(frankenSplice([1, 2], ["a", "b"], 1));
console.log(frankenSplice([1, 2, 3], [4, 5], 1))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Challenge Information:

Implement the Slice and Splice Algorithm - Implement the Slice and Splice Algorithm
https://www.freecodecamp.org/learn/full-stack-developer/lab-slice-and-splice/implement-the-slice-and-splice-algorithm

you are adding all values at index, so that means…
consider for example:
frankenSplice([1, 2], ["a", "b"], 1)
you add first “a” then “b” at index 1, so that means that the array becomes first [1, "a", 2], then [1, "b", "a", 2]

I suggest you read more about splice, you could figure out how to solve it

the other solution is to adjust the loop