title: How to exit in the middle of a function?
body: <p>How about nested if?</p>
  
  <pre><code>$scope.addToCart = function () {
      if (flagA) {
          if (flagB) {
              if (flagC) {
                  alert('nononono!');
                  return;
              }
          }
      }
      someAnotherFunction();
  };
  </code></pre>
  
  <hr>
  
  <p>I have a function:</p>
  
  <pre><code>$scope.addToCart = function () {
      var foo = 5;
      if (someFlag == 'Y') {
          alert('warning!');
          return;
      }
      someAnotherFunction();
  };
  </code></pre>
  
  <p>I invoke this function somewhere </p>
  
  <pre><code>ng-click = "addToCart()"
  </code></pre>
  
  <p>My intention is to exit this function if </p>
  
  <pre><code>someFlag == 'Y'
  </code></pre>
  
  <p>then not to execute </p>
  
  <pre><code>someAnotherFunction();
  </code></pre>
  
  <p>But it still execute it.</p>
  
  <p>WebStorm tell me this <code>return</code> is unnecessary so it could be safely removed.</p>