How to make javascript code clearer?
<p>I have five star rating and average score.</p>

<blockquote>
  <ol>
  <li>Average score is float number</li>
  <li>Five star rating just 10 section, one star have two half star (so 10 section is five star)</li>
  </ol>
</blockquote>

<p>Ex: </p>

<pre><code>Average score is: from 0 - 5 (average = 4.658, or average = 0.256, 0 &lt;= average &lt;= 5)

Five star rating is 10 section: [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
</code></pre>

<p>How to check and set average score to 10 section base on average score?</p>

<p>This is my code, it very long.</p>

<pre><code>            var twofixed = Math.round(average * 100) / 100;           
            twofixed = Math.abs(twofixed);
            var decimal = twofixed - Math.floor(twofixed)

            twofixed = (twofixed + "").split(".");

            if(twofixed[0] == 0)
            {
                if(twofixed[1] == undefined) { average = 0; }
                else
                {
                    if(twofixed[1] &lt;= 99)
                    {
                        average = 0.50;
                    }
                    else
                    {
                        average = 1;
                    }
                }
            }
            else if(twofixed[0] == 1)
            {
                if(twofixed[1] == undefined) { average = 1; }

                else
                {
                    if(twofixed[1] &lt;= 99)
                    {
                        average = 1.50;
                    }
                    else
                    {
                        average = 2;
                    }
                }
            }
            else if(twofixed[0] == 2)
            {
                if(twofixed[1] == undefined) { average = 2; }
                else
                {
                    if(twofixed[1] &lt;= 99)
                    {
                        average = 2.50;
                    }
                    else
                    {
                        average = 3;
                    }
                }
            }
            else if(twofixed[0] == 3)
            {
                if(twofixed[1] == undefined) { average = 3; }
                else
                {
                    if(twofixed[1] &lt;= 99)
                    {
                        average = 3.50;
                    }
                    else
                    {
                        average = 4;
                    }
                }
            }
            else if(twofixed[0] == 4)
            {
                if(twofixed[1] == undefined) { status = 'Great'; average = 4; }
                else
                {
                    if(twofixed[1] &lt;= 99)
                    {
                        average = 4.50;
                    }
                    else
                    {
                        average = 5;
                    }
                }                    
            }
            else if(twofixed[0] == 5)
            {
                if(twofixed[1] == undefined) { average = 5; }
            }
</code></pre>

<p>Big thanks to @th3falc0n with small code, I write more than 50 line of code, but you can do with one line of code to solve of my long code.</p>

<p>Thanks everyone to help me, and sorry for unclearly question and bad english</p>
