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

Tell us what’s happening:

This code passed the test.
But i didn’t use the splice method.
Should i move to next or try another approach.

Your code so far

function frankenSplice(arr1, arr2, index) {
  let firstArr = [...arr1];
  let secArray = [...arr2];
  const before = secArray.slice(0, index);
  const after = secArray.slice((index), (arr2.length));
  let resultArr = [];

  for (const elem of before) {
    resultArr.push(elem);
  }

  for (const elem of firstArr) {
    resultArr.push(elem);
  }

  for (const elem of after) {
    resultArr.push(elem);
  }
  return resultArr;
}

console.log(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2));


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

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

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-slice-and-splice/579e2a2c335b9d72dd32e05c.md at main · freeCodeCamp/freeCodeCamp · GitHub

Your solution works from my end. Please try one of the following steps to move forward.

Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.

or - Try the step in incognito or private mode.

or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.

or - Ensure your browser is up-to-date or try a different browser.

I hope one of these will work for you.

I already passed the test.
I was worried about not using the splice method in my code as it is in the name of the lab test.
Thankyou for replying.

while it is part of the name of the challenge, the splice method is not required here

if you want to try with splice that would be more practice more, and more practice is always good

We have blurred this solution (with [spoiler][/spoiler] tags) so that users who have not completed this challenge can read the discussion in this thread without giving away the solution.