title: How to create on/off switch for a piece of code?
body: <p>I am pretty new at coding and I'm tinkering around with react. On my index.tsx section of React, I have a counter on the tab of the web page that counts by 5 and resets at 100. I'm wondering if there is a way to disable the counter and display something like &quot;Rainbow&quot;, without deleting the code for the counter.</p>
  <p>Basically like an on/off switch that will show &quot;Rainbow when &quot;off&quot; and counter when &quot;on&quot;.</p>
  <p>Here is the code for the counter:</p>
  <pre><code>let counter = 1;
  const intervalFunction = () =&gt; {
    document.title = &quot;Count is &quot; + counter;
    counter = counter + 5;
    if (counter &gt;= 100) {
      counter = 0;
    }
  </code></pre>