title: My code for Hackerrank challenge Service Lane doesn't work
body: <p>I'm doing a challenge in www.hackerrank.com named Service Lane at <a href="https://www.hackerrank.com/challenges/service-lane" rel="nofollow">https://www.hackerrank.com/challenges/service-lane</a>. I have checked my code very carefully but it's still wrong in some cases. Here is my code: (in Javascript)</p>
  
  <pre><code>function main() {
      var n_temp = readLine().split(' '), i, s;
      width = readLine().split(' ');
      for(var a0 = 0; a0 &lt; n_temp[1]; a0++){
          var i_temp = readLine().split(' '); s = 3;
          for (i=i_temp[0];i&lt;=i_temp[1];i++) {s = Math.min(s,width[i]); if (s == 1) break;}
          console.log(s);
      }
  }
  </code></pre>
  
  <p>The challenge has a list of numbers (stored in <em>width</em>, their values are between 1 and 3) and some test cases (include a starting number: <em>i_temp[0]</em> and an ending number: <em>i_temp[1.]</em>, both of which are inclusive). The mission is to get the smallest number in the elements from <em>i_temp[0]</em> to <em>i_temp[1.]</em> of <em>width</em>.<br>Here is one of the cases that don't work:<br><a href="https://hr-testcases-us-east-1.s3.amazonaws.com/1331/input02.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1465479684&amp;Signature=0P32CbVtdNkxdlXDSmEIly%2Fxh6k%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Input</a><br><a href="https://hr-testcases-us-east-1.s3.amazonaws.com/1331/output02.txt?AWSAccessKeyId=AKIAJAMR4KJHHUS76CYQ&amp;Expires=1465479667&amp;Signature=aKkSUoKQSiXezuGSo9MCdDJPSEw%3D&amp;response-content-type=text%2Fplain" rel="nofollow">Output</a><br>What is wrong with the code? It works successfully in some cases. Thanks for your help :D</p>