I am looking to create my own custom iteratee function for lodash differenceBy that will return an array of values greater than 5.
As per the documentation, the iteratee is used to "generate the criterion by which they're compared."
Here's an example from the documentation:
_.differenceBy([1, 2, 3, 5, 6], [1, 2, 3, 8, 10], Math.floor); // [5, 6]
In this scenario, Math.floor() is being used.
let iter_floor = (value) => {
return Math.floor(value);
};
let differenceBy = _.differenceBy([1, 2, 3, 5, 6], [1, 2, 3, 8, 10], iter_floor);
console.log(differenceBy); // [5, 6]
However, when I try the following:
let iter_greater = (value) => {
return value > 5;
};
let differenceBy = _.differenceBy([1, 2, 3, 5, 6], [1, 2, 3, 8, 10], iter_greater);
console.log(differenceBy); // []
An empty array is returned instead of the expected values greater than 5.
You can find the source code for lodash differenceBy here: https://github.com/lodash/lodash/blob/4.17.5/lodash.js#L6971
Could someone provide me with an example of how to write an iteratee function for this specific case?
Thank you.