title: If/Else statement nested in While loop
body: <p>(I am very new to JavaScript and am writing this to try and get used to using it a bit more - which is why I'm using an object to store usernames and passwords. I'm learning this as part of an apprenticeship but this is during my own time to further my knowledge on JS)
  I have tried writing a small piece of code that should ask the user to enter a username, which will be cross-checked against the property names in the object "<em>userNames</em>". The user is then asked to enter a password for this user which is then checked against the password set as the value of the corresponding property with the right username. 
  I feel as though part of the problem is to do with me trying to use the variable "<em>enteredPassword</em>" (set to the user's input for the password as a method) of "<em>userNames</em>". 
  If the username or password are incorrect after 3 attempts then I'd like the window to close.
  my text editor is saying that the If statement is missing a branch and I'm not sure if this is affecting whether this works or not.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var userNames = {Tom:"PassW0rd", Bill:"Apples40C0lander", Ryan:"M1911p4ck4ge"};
  var Greeting = "Insert Username:";
  
  var i = 0;
  while (i &lt; 3)
  {
      var enteredUserName = prompt(Greeting);
      var enteredPassword = prompt("enter password for " + enteredUserName);
  
      if ((userNames.hasOwnProperty(enteredUserName)) &amp;&amp; (userNames.enteredUserName==enteredPassword)) {
          alert("Welcome");
          break;
      } else {
          alert("incorrect Username or Password");
          alert("");
          window.open('', '_self', ''); window.close();
          window.open('', '_self', ''); window.close();
          i++
      }}</code></pre>
  </div>
  </div>
  </p>