If you have an array of numbers and use the method push to add some of the elements on it. The specific elements have to remove from the array, So to resolve the issue in a simple way,

The option is, find the index of the array elements by indexOf and remove the index with splice.


const array = [10, 20, 30, 40];

## output of all the elements
console.log(array);

const index = array.indexOf(30);
if (index > -1) {
  array.splice(index, 1);
}

// array = [10, 20, 30]
console.log(array); 



The output should be,


[
  10,
  20,
  20,
  40
]
[
  10,
  20,
  40
]