title: Check if an array is descending, ascending or not sorted?
body: <p>I'm just beginning with programming using javascript and I need to practice some questions to get EXP with the logic of code build.
  I got this question for homework but I can't make it work for some reason, even though it seems "logic" to me.
  Check if an array is descending, ascending or not sorted using loops.</p>
  
  <p>I'm just a noob so please try and help me figure this out as I only got to loops in my studies (:
   this is the code I wrote:</p>
  
  <pre><code>        var array = [1, 2, 3, 7 ];
          var d = 0;
          var c =0 ;
          var b = 1;
          var a = 0;
          for (var i = 1; i &lt;= array.length; i++)
              {
                  if (array[c]&lt;array[b] &amp;&amp; a!== -1  ){
                     d = -1;
                     c =c+1;
                     b = b+1;
                     if(c==array.length){
                      console.log("asc");
                       break;
                     }else{
                       continue;
                  }
  
                  } else if (array[c]&gt;array[b] &amp;&amp; d!==-1 ){
                             a = -1;
                             d= d+1;
                             b = b+1;
                      if(i=array.length){
                      console.log("dsc");
                      break;
                 }else{continue;}
  
                 } else{
  
                      console.log("unsorted array");
                      break;
                  }
  
              }
  </code></pre>