Cookie Clicker Switches
Responses


  Does the code make sense to you? 


Yes, for the most part. I am still becoming acquainted with the game play and hacks.


  anything I could make better or more efficient?


In general, using an integer 0/1 instead of boolean would lead to faster performance1. To change the value, the bitwise NOT operator (i.e. ~) can be used. Note that applying NOT on a signed integer will yield -` but that is still a truthy value. While it was asked more than 6 years ago, this post has some interesting discussion on that matter.





var wrathCookieSwitchOn = 0;
var cookieSwitchOn = 0;

var wrathSwitch = function() {
  wrathCookieSwitchOn = ~wrathCookieSwitchOn;
  console.log("WrathCookieSwitchOn is set to " + wrathCookieSwitchOn);
}

function checkWrathCookieSwitchOn() {
  if (wrathCookieSwitchOn) {
    console.log('wrathCookieSwitchOn',wrathCookieSwitchOn);
  }
}
wrathSwitch();
checkWrathCookieSwitchOn();
wrathSwitch();
checkWrathCookieSwitchOn();




Other thoughts

Ternary vs Short-circuiting logical operators

As I mentioned in an answer to your previous post, the ternary could be simplified from:


(shimmer.type == "golden") &amp;&amp; (shimmer.wrath == 0 || wrathCookieSwitchOn) ? shimmer.pop() : 0;



To: 

(shimmer.type == "golden") &amp;&amp; (shimmer.wrath == 0 || wrathCookieSwitchOn) &amp;&amp; shimmer.pop();


While it only saves about 2 keystrokes, it is essentially like removing an else clause from an if statement.

Variable declaration

The declaration of the timer variable SpecialCookieClicker is within the true block of the if statement. While hoisting allows the variable to exist throughout the function, 
"it is recommended to always declare variables at the top of their scope"2 and then assign the value later (e.g.. 

var flipCookieSwitch = function(){
    var SpecialCookieClicker; //declare here
    cookieSwitchOn = !cookieSwitchOn;
    if (cookieSwitchOn) {
        SpecialCookieClicker = setInterval(/*function */, 500); //assign here
    }
}


While it should be the case that SpecialCookieClicker will always be assigned before the else block, it may be wise to guard against the scenario of an undefined value (e.g. due to cosmic rays) and ensure it is at least truthy before calling clearInterval().

SpecialCookieClicker &amp;&amp; clearInterval(SpecialCookieClicker); 


Variable names

The word On in variables wrathCookieSwitchOn and cookieSwitchOn convey the sense that the switch is on when the variable is true. Without the word On it could still be considered semantically the same - so one could argue that the names could be shortened to wrathCookieSwitch and cookieSwitch without any loss of semantics

ES-6

Presuming you aren't using IE, you should be able to utilize ES-6 features, like const for values that shouldn't be re-assigned and let for variables that can change. Then the one-liner for that function to pop shimmers can be simplified with an arrow function:

Game.shimmers.forEach((shimmer) =&gt; (shimmer.type == "golden") &amp;&amp; (shimmer.wrath == 0 || wrathCookieSwitchOn) &amp;&amp; shimmer.pop(), 500);




1https://jsperf.com/bool-vs-int/8

2https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting