Alternative of Array.prototype.flat() method

I am solving this challenge in freeCodeCamp.I completed this using Array.prototype.flat() method.But feeling unsatisfied cus, in the previous lesson I didn’t learn Array.prototype.flat() method. That’s why thinking alternative that fix this problem with previous lessons.
Is there any way to make it?
My code:

function frankenSplice(arr1, arr2, n) {
  let copyArr2 = [...arr2];
  return copyArr2.flat();

frankenSplice([1, 2, 3], [4, 5, 6], 1);

you are inserting arr1, how do you insert the elements of the array instead?

1 Like


function frankenSplice(arr1, arr2, n) {

let arr3 = […arr2]

arr3.splice(n, 0, …arr1)

return arr3;


1 Like

Oh,ya :relaxed:
Is that a good way?

  for(let i = 0; i < arr1.length; i++){

Woow :heart_eyes:
Thank you!

1 Like