title: Is it a bad practice to use multiple nested If Else statements?
body: <p>I'm trying to make a validator for an interface to change the password, and while making it I realized that I was using a lot of <code>if else</code> statements. I was wondering if there's a better way to do it.</p>
  
  <p>My Code :</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>function changePassword() {
  
    var testPassword = "user";
    var oldPassword = document.getElementById('password-old').value;
    var newPassword = document.getElementById('password-new').value;
    var newPasswordRepeat = document.getElementById('password-new-repeat').value;
  
    if (oldPassword === testPassword) {
      if (newPassword !== newPasswordRepeat) {
        alert("The passwords don't match");
      } else {
        if (newPassword === "") {
          alert("New password can't be blank");
        } else {
          alert("Password was changed successfully");
        }
      }
    } else {
      alert("Incorrect Password")
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;label for="password-old"&gt;Old Password&lt;/label&gt;
  &lt;input type="text" id="password-old" /&gt;
  
  &lt;label for="password-new"&gt;New Password&lt;/label&gt;
  &lt;input type="text" id="password-new" /&gt;
  
  &lt;label for="password-new-repeat"&gt;Re-Enter New Password&lt;/label&gt;
  &lt;input type="text" id="password-new-repeat" /&gt;
  
  &lt;input type="button" value="Confirm" onclick="changePassword()" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Is there a shorter way to do it or should I keep it as it is?</p>