title: javascript: stop certain loops and not others [enable/disable]
body: <p>How could I enable/disable certain loop that contains user input</p>
  <pre><code>const prompt = require('prompt-sync')();
  const readline = require('readline');
  
  readline.emitKeypressEvents(process.stdin);
  if (process.stdin.isTTY) process.stdin.setRawMode(true);
  
  process.stdin.on(&quot;keypress&quot;, (str, key) =&gt; {
      if(key.name == &quot;a&quot;) {{var fruit = prompt('input');}
  function loop() {
  console.log(&quot;test 123123 &quot;+fruit)}
  
  time = setInterval(function(){loop()},6000)}})
  </code></pre>
  <pre><code>test 123123 apple  (loop1/userinput1)
  test 123123 orange (loop2/userinput2)
  </code></pre>
  <p>how could I stop just the orange loop and keep the other and also how could i stop duplicates so that the same input can't be looping at the same time.</p>
  <p>ex...</p>
  <ul>
  <li>someone enters something like &quot;apple&quot;</li>
  <li>it would start printing</li>
  <li>then they also enters &quot;orange&quot;</li>
  <li>they decide I don't wanna loop &quot;orange&quot; anymore they enter &quot;orange&quot; again that turns off &quot;orange&quot; but keeps printing &quot;apple&quot;</li>
  </ul>