Question: I need to design a global boolean with 2 conditions a and b such that if A is ever true, the boolean is true until b is true, at which point the boolean is false. In other words, if A becomes false the boolean remains true.

I tried a straightforward global variable but it became false when A became false.

Preferably JavaScript, but pseudocode would be almost as helpful.

Answer: 
If I understand your question correctly, it should be fairly easy to match those cases with

```
var bool = (a != b);
/*
    (false != false) = false
    (true != false) = true
    (false != true) = true
    (true != true) = false
*/

```

With your changes, you could create a global variable `var aWasEverTrue = a;` and then instead of setting `a` directly, use a function such as `setA(true)`.

```
var a = false;
var b = false;
var aWasEverTrue = a;
function setA(newAValue) {
    aWasEverTrue = true;
    a = newAValue;
}

// (aWasEverTrue != b) = false

setA(true);
// (aWasEverTrue != b) = true

b = true;
// (aWasEverTrue != b) = false

setA(false);
// (aWasEverTrue != b) = false (as aWasEverTrue is still true)

b = false
// (aWasEverTrue != b) = true

```
Based on some assumptions about how B should behave if A has not been true:

```
function FlipFlop(){
    this.latch = false;
    this.value = false;
}

FlipFlop.prototype = {
    constructor: FlipFlop,

    setA: function( val ) {
        this.latch = this.latch || !!val;
        this.value = this.latch;
    },

    setB: function( val ) {
        if(this.latch && !!val) {
            this.latch = false;
        }
        this.value = !val;
    },

    getVal: function() {
        return this.value;
    }
}

```