Search code examples
javascriptbooleanboolean-logicboolean-operations

Boolean Algebra - How to Simplify


Working in JS and just started learning about boolean algebra. Wondering if there is a way to simplify this expression:

(!variableOne || !variableTwo)

I recall hearing something about how two 'nots' means you can change the sign, but I'm not seeing much about this when I google 'boolean algebra'.

Thanks!


Solution

  • You could take De Morgan's laws:

    !(a && b) = !a || !b 
    !(a || b) = !a && !b
    

    In your case it is

    !(variableOne && variableTwo)