title: Input validation JavaScript?
body: <p>I need to ask the user a prompt but they are only able to enter certain words for it to accept the answer, if the user does not answer with the right words it then say it is invalid and asks the question again.<br>
   This has to be done by only using javascript.</p>
  
  <pre><code>var entering = confirm('Confirm to add state or territory');
  if (!entering) {
      return;
  } else {
      while (true) {
          stInput = prompt('Enter state or territory');
  
          function validateUserChoice(stInput) {
              if (stInput !== "Queensland" &amp;&amp; stInput !== "New South Wales" &amp;&amp; stInput !== "Victoria" &amp;&amp; stInput !== "Tasmania" &amp;&amp; stInput !== "Northern Territory" &amp;&amp; stInput !== "Western Australia" &amp;&amp; stInput !== "South Australia" &amp;&amp; stInput !== "Australian Capital Territory") {
                  alert("invalid state or territory");
              } else {
                  return false;
              }
          }
          populationInput = parseInt(prompt('Enter population for ' + stInput + ''));
  
          while (isNaN(populationInput)) {
              alert('Your input was invalid');
              populationInput = parseInt(prompt('Enter population for ' + stInput + ''));
          }
          changeInput = parseFloat(prompt('Enter growth rate for ' + populationInput + ''));
  
          while (isNaN(changeInput)) {
              alert('Your input was invalid');
              changeInput = parseFloat(prompt('Enter growth rate for ' + populationInput + ''));
          }
  
          break;
      }
  
  }
  </code></pre>
  
  <p>This is what I have done so far but it is not validating so it I have done something wrong just not sure what.</p>
  
  <p>The words the user can only answer with are: <code>Queensland</code>, <code>New South Wales</code>, <code>Victoria</code>, <code>Tasmania</code>, <code>Northern Territory</code>, <code>Western Australia</code>, <code>South Australia</code>, <code>Australian Capital Territory</code>.</p>