This completely replaces your switch
statement by using inline if statements conditional operator:
$box.hide().delay(val < 50 ? 300 : 0);
var s = val > 50 ? 'XN' : (val < 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 < 50 && $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 < 50
val < 50 && $box.delay(300);
var s = val > 50 ? 'XN' :
(val < 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.
switch
can be used with expressions, you should better only use literal/constant values. \$\endgroup\$