Question: How do I check if a value has been incremented in JS?

```
var count = 0; 

function A () {
    /// creates random nodes
    /// does some math, outputs e1, e2, e3, etc
    count ++; 
    }

function toggle(count) {
    if (count ++ occurred) && (toggle.checked) {
    /// then take e1, e2, e3 and store in array X ...
    /// take array X and count, put into CSV file, send to designated email 
       }
    }

```

I have function A working fine, but the tricky part is how to record the e1, e2, e3 into array X only when the toggle is on.

Thanks in advance.

Answer: 
You can use a `boolean` variable to check if `count` has been incremented. After checking it's status once, it's state should be reseted to prepare it for the next check.

```
var count = 0; 
let incremented = false;

function a {
  /// does some stuff
  count ++; 
  incremented = true;
}

function b(count) {
  if ( incremented && toggle.checked ) {
    /// then do xyz...
    incremented = false;
  }
}

```
If you need to check that at least once the variable *count* is incremented, you can use directly *count* as condition:

```
function b(count) {
    if (count) && (toggle.checked) {
    /// then do xyz...
       }
}

```

In JS if a variable x is 0, will be considered as "false" in a IF statement.