Animating one of three boxes based on a form value Is there a better way to do this without using if or case statements?

var val = ui.value,
$box = $('#message');
switch(true) {
  case (val &gt; 50):
    $box.hide();
    animations.animateBox($box.html('you have chosen XN'));                        
    break;
  case (val &lt; 50):
    $box.hide().delay(300);
    animations.animateBox($box.html('you have chosen VN'));
    break;
  default:
    $box.hide();
    animations.animateBox($box.html('you have chosen PN'));
}
This completely replaces your switch statement by using inline if statements conditional operator:

$box.hide().delay(val &lt; 50 ? 300 : 0);
var s = val &gt; 50 ? 'XN' : (val &lt; 50 ? 'VN' : 'PN');
animations.animateBox($box.html('you have chosen ' + s));


the first line could be replaced by these two arguably more readable lines that omit the call to delay() function when not applicable:

$box.hide();
val &lt; 50 &amp;&amp; $box.delay(300);


Since @GregGuida pointed out that this code is less readable I suppose I can make it more readable by better formatting it. And I'll use the suggestion of replacing the first line with two of them:

$box.hide();

// only delay animation when value &lt; 50
val &lt; 50 &amp;&amp; $box.delay(300);

var s = val &gt; 50 ? 'XN' :
       (val &lt; 50 ? 'VN' :
                   'PN');
// set HTML
animations.animateBox($box.html('you have chosen ' + s));


Same code but visually less chaotic (even without comments it would look less chaotic) and much much more readable. At least much more readable than OP's original code. That I'm sure of. Readability is of course an argumentative disposition. But I'll leave that to others.