0

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.

JLRishe
  • 99,490
  • 19
  • 131
  • 169
Sepehr Sobhani
  • 862
  • 3
  • 12
  • 29

1 Answers1

5

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

const formatCity = R.when(R.both(has('city'), has('state')), appendCommaToCity);
Bergi
  • 630,263
  • 148
  • 957
  • 1,375