Getting a compass point from 140° This JavaScript converts degrees to a compass point, e.g. convert.toCompass(140) gets 140° -&gt; SE.

I can't help but think: is there a more concise way to do this?

var convert = {
    toCompass: function(degrees)
    {
        if(degrees &gt;= 0 &amp;&amp; degrees &lt;= 11.25)
        {
            return 'N';
        }

        else if(degrees &gt; 11.25 &amp;&amp; degrees &lt;= 33.75)
        {
            return 'NNE';
        }

        else if(degrees &gt; 33.75 &amp;&amp; degrees &lt;= 56.25)
        {
            return 'NE';
        }

        else if(degrees &gt; 56.25 &amp;&amp; degrees &lt;= 78.75)
        {
            return 'ENE';
        }

        else if(degrees &gt; 78.75 &amp;&amp; degrees &lt;= 101.25)
        {
            return 'E';
        }

        else if(degrees &gt; 101.25 &amp;&amp; degrees &lt;= 123.75)
        {
            return 'ESE';
        }

        else if(degrees &gt; 123.75 &amp;&amp; degrees &lt;= 146.25)
        {
            return 'SE';
        }

        else if(degrees &gt; 146.25 &amp;&amp; degrees &lt;= 168.75)
        {
            return 'SSE';
        }

        else if(degrees &gt; 168.75 &amp;&amp; degrees &lt;= 191.25)
        {
            return 'S';
        }

        else if(degrees &gt; 191.25 &amp;&amp; degrees &lt;= 213.75)
        {
            return 'SSW';
        }

        else if(degrees &gt; 213.75 &amp;&amp; degrees &lt;= 236.25)
        {
            return 'SW';
        }

        else if(degrees &gt; 236.25 &amp;&amp; degrees &lt;= 258.75)
        {
            return 'WSW';
        }

        else if(degrees &gt; 258.75 &amp;&amp; degrees &lt;= 281.25)
        {
            return 'W';
        }

        else if(degrees &gt; 281.25 &amp;&amp; degrees &lt;= 303.75)
        {
            return 'WNW';
        }

        else if(degrees &gt; 303.75 &amp;&amp; degrees &lt;= 326.25)
        {
            return 'NW';
        }

        else if(degrees &gt; 326.25 &amp;&amp; degrees &lt;= 348.75)
        {
            return 'NNW';
        }

        else if(degrees &gt; 348.75 &amp;&amp; degrees &lt;= 360)
        {
            return 'N';
        }
    }
}
By looking at values in your series of if's, you can make an array ([]), then calculate which index to pick:

var convert = {
    toCompass: function(degrees)
    {
        return ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'][Math.round(degrees / 11.25 / 2)];
    }
}

alert(convert.toCompass(140));      // SE


JSFiddle demo