Funktion abbrechen 2

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 id="html"></div> <script> const max=100; const min=0; const hoch=10; const menge=5; var helper=0; const nicht_hoeher=99; button_html=document.getElementById('html'); for(l=0;l<menge;l++){ button_html.innerHTML+=` <div class="row"> <button class="Button" data-helfer="${l},1">Button +</button> <p class="ausgang">0</p> <button class ="Button" data-helfer="${l},2">Button -</button> </div>`; } butt=document.querySelectorAll('button'); butt.forEach(function(b){ b.addEventListener('click',function(){ arr=b.getAttribute('data-helfer'); arr=arr.split(','); weiter3(arr[0],arr[1]); }); }) function weiter3(vari,was){ ge=document.querySelectorAll('.ausgang'); helper=0; ge.forEach(function(b){ helper+=parseInt(b.innerHTML); }) if(helper>nicht_hoeher && was==1){ return; }else{ helper-=hoch; } 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>