Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice

Tell us what’s happening:
Describe your issue in detail here.

this has nothing to do with the challenge. my problem concern the example that was shown on this challenge, that when you u want to do a splice(3,2) , the 3rd and 4th element gets spliced. i can see the third by the fourth doesnt make sense considering the ending index is at 2.
Your code so far


const arr = [2, 4, 5, 1, 7, 5, 2, 1];
// Only change code below this line

// Only change code above this line
console.log(arr);

Your browser information:

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

Challenge: Remove Items Using splice()

Link to the challenge:

The second argument is not a stop index. It is a number of elements to slice out.

oh i see that explains alot. . so that explains why the other example spliced out the element 3 and 4 after (2,2). so confusing because python splicing is way different.

the js slice method works more like you are thinking, the splice method has this different syntax

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.