title: I have issue with registration and login
body: <p>I have issue with registration and login. Actually when the password is less than 8 char it's showing alert password should be >8, but still it's adding inside the object, in the same way it's not showing any error if two user names are same.Again, when i click on login with correct credentials it's showing incorrect username &amp; password and it's showing logged in How can i solve this? Any leads, Totally new to programming. </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 objPeople = [
   {
    username: 'hello',
    password: '12345678'
   },
   {
    username: 'cat',
    password: 'password123'
   },
   {
    username: 'dreamer',
    password: 'password13'
   }
  ]
  
  function login() {
   
   var username = document.getElementById('username').value
  
   var password = document.getElementById('password').value
  
   
   for(var i = 0; i &lt; objPeople.length; i++) {
   
    if(username == objPeople[i].username &amp;&amp; password == objPeople[i].password) {
     console.log(username + ' is logged in!!!')
    
     break
    } else {
     
     console.log('incorrect username or password')
    }
   }
  }
  
  
  function registerUser() {
   var registerUsername = document.getElementById('newUsername').value
   
   var registerPassword = document.getElementById('newPassword').value
   
   var newUser = {
    username: registerUsername,
    password: registerPassword
   }
   for(var i = 0; i &lt; objPeople.length; i++) {
    
    if(registerUser == objPeople[i].username) {
     alert('That username is alreat in user, please choose another')
     
     break
    
    } else if (registerPassword.length &lt; 8) {
     
     alert('That is to short, include 8 or more characters')
    
     break
    }
   }
   
   objPeople.push(newUser)
   
   console.log(objPeople)
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
     &lt;h2&gt;Login&lt;/h2&gt;
     &lt;input type="text" id="username"&gt;
     &lt;input type="password" id="password"&gt;
     &lt;button type="button" onclick="login()"&gt;Login&lt;/button&gt;
    &lt;/form&gt;
    &lt;!-- register user form --&gt;
    &lt;form&gt;
     &lt;h2&gt;Register&lt;/h2&gt;
     &lt;input type="text" id="newUsername"&gt;
     &lt;input type="password" id="newPassword"&gt;
     &lt;button type="button" onclick="registerUser()"&gt;Register&lt;/button&gt;
    &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>