how to make a if loop happen repeat once

JavaScript
//this is a long example but it workes for me
//it makes the "code" happen as soon as criteria1 is true then it starts a timer
//until it can happen agen

if ( criteria1 ) {
      this.switch = true
    } else {
      this.switch = false
    }
    if (this.switch == false) {
      this.counter = this.counter + 1
      
    }
    if (this.counter > timer && this.switch == true) {
      the code used (code)
      this.C1 = 0
      
    }
Source

Also in JavaScript: