Is there a better way to achieve increment and decrement?
<p>I am doing an animation for which I need to move my div by 25px. Once the div reached 25px it should flip back to 0px, it should not stop any way. For that, I need a function to loop the div. This is what I have so far:</p>

<pre><code>    var x = 0;
    var condition = true;

    var loopIt = function (){
        while(x &lt; 25 &amp;&amp; condition == true){
            x++;
            console.log(x);
            if(x == 25){
                condition = false;
            }
        }   

        while(x &gt; 0 &amp;&amp; condition == false){
            x--;
            if(x == 0){
                condition = true;
            }
            console.log(x);
        }
        setTimeout(loopIt, 1000);
    }

    loopIt();
</code></pre>

<p>It is working good, but i feel this is ugly. Is there any shorter way to archive the same?</p>
