Skip to content
Advertisement

Ramda: How to remove keys in objects with empty values?

I have this object:

JavaScript

I need to remove all key/value pairs in this object where the value is blank i.e. ''

So the caste: '' property should be removed in the above case.

I have tried:

JavaScript

But this doesn’t do anything. reject doesn’t work either. What am I doing wrong?

Advertisement

Answer

You can use R.reject (or R.filter) to remove properties from an object using a callback:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement