DEV Community

loading...

Discussion on: 2 Tips to Clean Ugly if Statements

Collapse
tirthaguha profile image
Tirtha Guha

For #1 Complex condition expressions
I would prefer writing the complex condition, as it is simpler than 3 if statements.

function isColdOutside(temp, gusts, snowing){
  return ((temp === 0) || (temp > 0 && temp < 5 && gusts > 10) || (snowing))
}
Enter fullscreen mode Exit fullscreen mode