I would break this down into smaller functions:
withJam
Returns true
if a string contains the string jam
(case insensitive)
const withJam = R.test(/jam/i);
withJam('Bill') //=> false
withJam('James') //=> true
nameWithJam
Returns true
if a property contains the string jam
(case insensitive)
const nameWithJam = R.propSatisfies(withJam, 'name');
nameWithJam({name: 'Bill'}) //=> false
nameWithJam({name: 'James'}) //=> true
Then you can write:
R.reject(nameWithJam)(people)
I think that your initial solution is good enough already. I just made it pointfree, i.e. without mentioning the parameters explicitly.
Example:
Let's say that you need a function that adds 5
to any number:
const add5 = n => n + 5;
add5(37) //=> 42
You could get rid of n
if you could work with a curried version of add
. Let's define add
first:
const add = m => n => m + n;
Then let's create add5
:
const add5 = add(5);
add5(37) //=> 42
You can replace this:
[1,2,3].map(n => n + 5) //=> [6,7,8]
With:
[1,2,3].map(add(5)) //=> [6,7,8]
⚠️ Pointfree style is certainly interesting and worth exploring. But it can also unnecessarily complicate things :) See When is it appropriate to choose point-free style vs a data-centric style in functional programming?