clearInterval isn't functioning properly <p>This is my code that auto adds a certain amount "points" or gold every second depending a varable but when that variable variable changes which is done by a button that runs this command to stop the set Interval isn't functioning. Please help me figure this out.</p> <pre><code>function addMiner() { clearInterval(autoClick) if (localStorage.getItem('minercount') &gt; 0) { var autoClick = setInterval(function() { miner() }, 1000); document.getElementById("goldNumber").innerHTML = localStorage.getItem('clickcount'); } } </code></pre>