title: Fallthrough issue in Javascript switch statement
body: <p>I have a large array of features with p and u properties. I want to find the smallest and highest p and u in the array and create this switch statement in a loop. This works about 99.9% of the time. However. I have one data set where the max and min turn out to be the same even if the values are evenly distributed and the average is not the same. Stumped.</p>
  
  <pre><code>            switch(true) {
                  case p &gt; max_p:
                      max_p = p;
                  case u &gt; max_u:
                      max_u = u;
                  case p &lt; min_p:
                      min_p = p;
                  case u &lt; min_u:
                      min_u = u;
              }
  </code></pre>
  
  <p>I run through the loop in firebug and can see that max_u gets sometimes updated if u &lt; max_u. For example u = 0.066, max_u = 0.088.</p>
  
  <p>Pycharm tells me about a fallthrough issue but the statement works fine on every other dataset I throw at it.</p>
  
  <p>I can split the statement into two. The performance loss is minor but I would like to understand how this could happen.</p>
  
  <p>Thanks,
  Dennis</p>
  
  <p>edit:</p>
  
  <p>Split into two statement that dataset works completely fine without a break in the statement.</p>
  
  <pre><code>            switch(true) {
                  case p &gt; max_p:
                      max_p = p;
                  case p &lt; min_p:
                      min_p = p;
              }
              switch(true) {
                  case u &gt; max_u:
                      max_u = u;
                  case u &lt; min_u:
                      min_u = u;
              }
  </code></pre>
  
  <p>edit: I accepted the answer given which works but I am still puzzled why something like this would happen.</p>
  
  <p><a href="https://i.stack.imgur.com/lCoOk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lCoOk.png" alt="enter image description here"></a></p>