<script type="text/javascript"> var a = []; for ( var i = 0, n = 1; i < 10; i++, n = i > 5 ? --n : ++n ) a.push( n ); document.write( a ); </script>