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

Tell us what’s happening:

Hey,
I am not sure if this is what was supposed to be used to pass the lab.
For the last while, labs were needing loops to complete. And I was not sure if this also needed to use loops for the result.

I passed the lab and I read that the code was not to have fully functioning ones be posted.
seeing as the code i had was pretty much 1 line within a return. Was it wanting me to do something else, I will type out what i had in the code rather than the code itself.

Your code so far

within the function using only one item within
a return from the function was
array 2 was sliced from start to the index
array 2 had been sliced from the index
array 1 was added where needed
three dots used to bring in the arrays

Your browser information:

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

Challenge Information:

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

I’m not sure I’m understanding why you are posting. You said your code is passing, right? If you are looking for feedback on your working solution, you can surround your code 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.


frankenSplice(arr1, arr2, index){
  return [
    ...arr2.slice(0, index),
    ...arr1,
    ...arr2.slice(index)
  ];
}

I was posting this only because I am not sure if this lab was intended to have us loop through it like the last several labs have been or if what I have used here and passed with is okay. If its not the intended route the lab was wanting I will go back and try to pass it in the way it was intended.

This felt very easy Compared to most of the recent ones and I feel like I did it wrong because of that.

this one is in the Fundamentals Review section, as long as you are practicing the fundamentals you are doing what the lab is for

if you want to practice, you can find one or two more different ways to solve this

Ah, so it is.

Sorry about that, Thank you both for replying.
I see you edited my last message due to not getting the spoiler tag to work, Can you explain how to use it please.
I tried putting the code into the box that appears once you do [ spoiler ] but it did not blur.

Thanks again.

If you click on your blurred code, you can see that spoiler and /spoiler were used (without the brackets). ILM probably fixed it. I was copying from a template, so I’m glad you are asking for clarification.

Perfect thanks.
I did have the spoiler /spoiler in the javascript code portion too but i did not see any differences visually.
Trying myself below

Testing to see if blurred.

Thanks again for the replies guys, enjoy the rest of the weekend.

I was wrong. The brackets are required. I just tested on your last post.