79574419

Date: 2025-04-15 05:23:32
Score: 0.5
Natty:
Report link

Using splice() (Modifies Original Array)

const array = [1, 2, 3, 4, 5];
const index = array.indexOf(3); // Find index of item to remove
if (index > -1) { // Only splice if item exists
   array.splice(index, 1); // Remove 1 item at found index
}
console.log(array); // [1, 2, 4, 5]
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Ashish radadiya