discard
discard
(values: ValueCollection) => (collection: Collection) => Collection
Discard all
values
from the collection.const discardOnesAndTwos = discard([1, 2]) discardOnesAndTwos([1, 2, 3, 4, 1]) // is [3, 4]
const discardOnesAndTwos = discard([1, 2]) discardOnesAndTwos([1, 2, 3, 4, 1]) // is [3, 4]
const discardOnesAndTwos = discard([1, 2]) discardOnesAndTwos([1, 2, 3, 4, 1]) // is [3, 4]
const discardOnesAndTwos = discard([1, 2]) discardOnesAndTwos([1, 2, 3, 4, 1]) // is [3, 4]
Sometimes we don't want certain values. Below, Ken doesn't like green or yellow Skittles. Let's discard them.
const handful = ['green', 'orange', 'red', 'yellow', 'purple', 'green'] const discardGreenAndYellow = discard(['green', 'yellow']) const goodSkittles = discardGreenAndYellow(handful) console.log(goodSkittles) // is ['orange', 'red', 'purple']
const handful = ['green', 'orange', 'red', 'yellow', 'purple', 'green'] const discardGreenAndYellow = discard(['green', 'yellow'])<string[]> const goodSkittles = discardGreenAndYellow(handful) console.log(goodSkittles) // is ['orange', 'red', 'purple']
const handful = [ 'green', 'orange', 'red', 'yellow', 'purple', 'green', ] const discardGreenAndYellow = discard([ 'green', 'yellow', ]) const goodSkittles = discardGreenAndYellow(handful) console.log(goodSkittles) // is ['orange', 'red', 'purple']
const handful = [ 'green', 'orange', 'red', 'yellow', 'purple', 'green', ] const discardGreenAndYellow = discard([ 'green', 'yellow', ])<string[]> const goodSkittles = discardGreenAndYellow(handful) console.log(goodSkittles) // is ['orange', 'red', 'purple']