if-statement Questions - SnippetGoodmost recent 30 from http://snippetgood.com2010-07-29T23:54:58Zhttp://snippetgood.com/feeds/tag/if-statementhttp://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://snippetgood.com/questions/89/if-statements-and-rangesIf statements and ranges miss snippet2009-10-13T17:23:45Z2009-11-11T04:45:33Z
<p>I have a JQuery script that I'm working on and in part of it, I am comparing a value to make sure it is within a specific integer range.</p>
<p>This is what my first attempt looks like:</p>
<pre><code>if (levelCounter < 0) { levelCounter = 0; }
if (levelCounter > maxLevels) { levelCounter = maxLevels;}
</code></pre>
<p>I'm hoping there's a shorter more efficient way to do this - I can't think of it off the top of my head.</p>