Funktion abbrechen

Hallo Leute,:) Wenn die Variable "Button" = 100 ist, sollen die Funktionen ButtonPush und ButtonPush2 pausiert werden. Außerdem soll die Variable nicht ins Negative rutschen. Wie mache ich das am besten (if-Anweisung) ?:unsure: Danke für eure Antworten:giggle:

Der hier verwendete Code

<!doctype html> <html lang="de"> <head> <style> *{ margin:0; padding:0; font-size:22px; } .row{ display:flex; width:300px; height:30px; } .row *{ flex:1; text-align:center; } </style> </head> <body> <div class="row"> <button class="Button" data-helfer="0,1">Button +</button> <p class="ausgang">0</p> <button class ="Button" data-helfer="0,2">Button -</button> </div> <div class="row"> <button class="Button" data-helfer="1,1">Button +</button> <p class="ausgang">0</p> <button class ="Button" data-helfer="1,2">Button -</button> </div> <div class="row"> <button class="Button" data-helfer="2,1">Button +</button> <p class="ausgang">0</p> <button class="Button" data-helfer="2,2">Button -</button> </div> <script> const max=100; const min=0; const hoch=10; but=document.querySelectorAll('Button'); but.forEach(function(f){ f.addEventListener('click',function(){ arr=f.getAttribute('data-helfer'); weiter(arr[0],arr[2]); }) }); function weiter(vari,was){ var output = document.getElementsByClassName("ausgang")[vari]; l=output.innerHTML; const g=was==1 ? 1 : 2; if(g==1){ z=parseInt(l)+hoch; }else{ z=parseInt(l)-hoch; } if(z>max){ z=max; } if(z<min){ z=min; } output.innerHTML=z; } </script> </body> </html>