Sepehr Sobhani
Sepehr Sobhani

Reputation: 882

How to make an if statement point free

I have the following if statement:

var formatCity = 
    obj => R.both(has('city'), has('state'))(obj) ? appendCommaToCity(obj) : obj

I would like to make this code point free, but can not figure out a way around the if statement.

Upvotes: 0

Views: 63

Answers (1)

Bergi
Bergi

Reputation: 664538

That's quite simple actually using the ifElse function - or its specialisation, when:

const formatCity = R.when(R.both(has('city'), has('state')), appendCommaToCity);

Upvotes: 5

Related Questions