79834441

Date: 2025-12-01 07:44:45
Score: 0.5
Natty:
Report link

With minor changes to the answer by @Ori Drori, here is a complete point-free style version where keys are passed as a parameter instead of being hardcoded:

import {pickBy, map} from 'ramda'

const users = [
    {
        id: 1,
        name: 'John',
        lastName: 'Smith',
        note: null
    },
    {
        id: 2,
        name: 'Jill',
        lastName: null,
        note: 'note 2',
    },
    {
        id: 3,
        name: null,
        lastName: 'Smith',
        note: null
    }
];


const removeNullExcept = (keys = []) => map(pickBy((val, key) => val !== null || keys.includes(key)))

const result = removeNullExcept(['note'])(users)
console.log(result)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Ori
  • Low reputation (0.5):
Posted by: Sam Raju