title: how to stop program execution after a condition becomes true
body: <p>I would like my program to stop execution after a condition becomes true. I'm writing code that tests a user input against a randomly generated number, if the guess is equal to the number generated I would like to prevent the user from being able to enter any more values and instead get a message telling them they've won the game. </p>
  
  <p>I have a simple form where the user enters their guess and clicks on a button to submit. The following is my function: </p>
  
  <pre><code>function parseGuess(guess){
  
  var diff = Math.abs(generatedNumber - guess);
  
      if(diff &gt;= 50){
              view.displayMessage("Ice cold");
  
          } else if (diff &gt;= 30 &amp;&amp; diff &lt; 50){
              view.displayMessage("Cold");
  
          } else if (diff &gt;= 20 &amp;&amp; diff &lt; 30){
              view.displayMessage("Warm");
  
          } else if (diff &gt;= 10 &amp;&amp; diff &lt; 20){
              view.displayMessage("Hot");
  
          } else if (diff &gt;= 1 &amp;&amp; diff &lt; 10){
              view.displayMessage("Very hot");
  
          } else if(guess === generatedNumber){
              gameOver = true; 
           view.displayMessage("Well done! You guessed the number in " + (controller.guesses + 1)+" guesses");
  
          }
  </code></pre>
  
  <p>}</p>
  
  <p>parseGuess is invoked inside the controller object that is called when the user clicks the button: 
      var controller = {</p>
  
  <pre><code>        guesses: 0,
  
              processGuess: function(guess) {
  
              var count = document.getElementById("count");   
  
              //var diff = Math.abs(generatedNumber - guess); 
  
  
  
              console.log(gameOver);
  
  
  
              if (guess &lt;=0 || guess &gt;=101 || isNaN(guess) || guess == "")
                  {   
                      return alert("Oops, please enter a number between 1 &amp; 100");
  
                  }
  
  
                  parseGuess(guess); 
                  this.guesses++;
  
                  addListElement(guess); 
                  count.innerHTML = this.guesses; //write the guess count into the span  
  
  
          return null;
      }
  }
  </code></pre>