For loop JS for a calculator : <p>I'm trying to create a calculator which goes through 18 units. I wanted to make my code shorter by using a for loop. I thought something like this would work:</p>

<pre><code>var i=0;
    for (i=0;i&lt;=18;i++)
    {
        if (Unit[i] = "P" or Unit[i] == "p")
        {
            UnitTotal[i] = 70;
            SetCookie('UnitAns'[i],UnitAns[i]);
        }
    }
</code></pre>

<p>This doesn't work what am I doing wrong or what do I need to do differently?</p>
