Question: I have an array and I want to delete some elements. My array is `arrayAuxiliar`. My code is the following one:

```
        for( var i = 0; i < arrayAuxiliar.length; i++)
        { 
            if (arrayAuxiliar[i] == valueFirts) {
                 arrayAuxiliar.splice(i,1);             
            }
            else if(arrayAuxiliar[i] == value){
                arrayAuxiliar.splice(i,1);  
            }
        }

```

Example of what is happening:

* Initial values: `arrayAuxiliar = [3,2,1], valueFirst = 1, value = 2`
* Final values: `arrayAuxiliar = [3,1]`

I know this happens because `splice()` changes the original array and that's for this reason the comparasion between `arrayAuxiliar[i] == valueFirts` is never true. I've also tried to use `remove arrayAuxiliar[i]` but it returns `[3,,]`.

How can I solve this situation in order to get the only element that does not verify the conditions which is `3`? The idea was the final result be `[3]` and I could get it by a `arrayAuxiliar[0]` command.

Answer: 
Use `filter` and `includes` method

```js
const array = [3, 2, 1]
const remove_list = [2, 1]

const res = array.filter(num => !remove_list.includes(num))

console.log(res)
```
Also you can use reduce function

```
function test(arrayAuxiliar, valueFirts, value) {
  return arrayAuxiliar.reduce((acc,rec) => {
    if ((rec === value) || (rec === valueFirts)) {
      return [...acc]
    }
    return [...acc, rec]
  }, [])
}
console.log(test([3,2,1,4,1,2,2,3,1,4,5,8,2,5], 1, 2))

```