title: Javascript, matching username and password with array values
body: <pre><code>var usernames = ["smith",  "tron",      "ace",      "ladyj",    "anon"];
  var passwords = ["qwerty", "EndOfLine", "year1942", "ladyj123", "PASSWORD"];
  var x = prompt("Please enter the username");
  var y = prompt("Please enter the password");
  
  function validate(usernames, passwords) {
      for (var i=0; i &lt;usernames.length; i++) {
          if ((x == usernames[i]) &amp;&amp; (y == passwords[i])) {
              valid = true;
              break;  
          }
      }
      if (valid) {
          alert("Valid Credentials");
      } else {
          alert("Invalid Credentials")
      }       
  }
  </code></pre>
  
  <p>So I'm trying to create a loop that checks the username and pass with the entered prompt, so basically when prompted to enter a username and the user enters "smith" the correct password should be "qwerty" or if the user enters "tron" the correct password the user enters should be "EndOfLine" otherwise an alert saying "invalid Credentials" should pop up. </p>
  
  <p>When I open the HTML file, I enter the user/pass but doesn't send any type of alert after entering the credentials.</p>