Basic Data Structures - Remove Items Using splice()

Tell us what’s happening:
Describe your issue in detail here.
Do I put let sum = 10?

Your code so far

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

// Only change code above this line

Your browser information:

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

Challenge: Basic Data Structures - Remove Items Using splice()

Link to the challenge:

The challenge says that you have to only keep the elements that add up to 10 in the array and remove the rest.
As you can observe the elements starting from index 1 to index 3 that is 4,5,1 add up to 10 so you have to keep these elements and remove the remaining using splice. Use splice to remove the first and the last 4 numbers from the array.
Hope this helps!

1 Like

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