MaxwellLynn MaxwellLynn - 10 months ago 36
Javascript Question

Remove value from array

I am trying to figure out how if you are adding values to an array and then the same value comes up you have push it to the same array to not push it up and remove the duplicate of the value from the array.

This is my code below:

if (!_.includes(scope.index, val)) {
} else {
_.remove(scope.index, val);


You have to call _.remove() with a predicate function which checks if the current element equals to val:

_.remove(arr, x=> x === val)