Remove Items Using splice() - JS Challenge

We can remove item using splice for the below challenge like this
Challenge in Data Structure with JS

Question is asking this:

We’ve initialized an array arr . Use splice() to remove elements from arr , so that it only contains elements that sum to the value of 10 .

const arr = [2, 4, 5, 1, 7, 5, 2, 1];
// Only change code below this line
arr.splice(0, 1);
arr.splice(3, 5);
// Only change code above this line

Try to get an array that contains only elements that sum to the value of 10 in one row. Numbers at indices 0, 5, 6, 7 in the given array will give the sum of 10. Using ‘splice’ method you should return an array without numbers at indices from 1 to 4.

1 Like

Thanks for your information!

By using one row, your answer is helpful!

Happy coding!

1 Like

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