Horje
NO "ELSE" STATEMENT IN THIS CODE Code Example
NO "ELSE" STATEMENT IN THIS CODE
this.go = function (currentState) {
    if (currentState == LightState.GREEN) {
      console.log("Green --> for 1 minute")
      this.change(LightState.YELLOW)
      return
      
    }
    if (currentState == LightState.YELLOW) {
      console.log("Yellow --> for 10 seconds")
      this.change(LightState.RED)
      return
    }
    if (currentState == LightState.RED) {
      console.log("Red --> for 1 minute");
      this.change(LightState.GREEN)
      return
    }
    if (currentState != LightState.GREEN && currentState != LightState.RED && currentState != LightState.YELLOW) {
      throw Error("Invalid State")
    }
}




Javascript

Related
how to upload document cloddinary Code Example how to upload document cloddinary Code Example
how to calculate number with arithmetic operators in javascript Code Example how to calculate number with arithmetic operators in javascript Code Example
karma error parent child Code Example karma error parent child Code Example
angularjs are you sure to leave Code Example angularjs are you sure to leave Code Example
how to show latest stock news in my webpage js quote? Code Example how to show latest stock news in my webpage js quote? Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7