title: How to write an IF else statement without 'else' in JavaScript
body: <p>I can't use <code>else</code> in my script; how can I implement an <code>if else</code> statement without using <code>else</code>?</p>
  <p>I'm trying to resize a div:</p>
  <pre><code>function hideTable(){
      var table = document.getElementById('PDemo');
      if(table.style.width == &quot;50%&quot;) table.style.width = &quot;150px&quot;;
      if(table.style.width == &quot;150px&quot;) table.style.width = &quot;50%&quot;;
  }
  </code></pre>
  <p>This script doesn't work because as soon as the first <code>if</code> statement is executed, the condition for the second <code>if</code> statement becomes true, so that executes too, and thus nothing changes.</p>