title: How do I get the current school hour and time remaining?
body: <p>I have this function:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function getInfoSchoolTime() {
   var date = new Date();
   var schoolBellTime = ["8:10","9:02","9:54","9:59","10:51","11:43","11:58","12:48","13:35","13:40","14:10","15:02","15:54"];
   var remainingTime, currentHour;
  
   for (var i = 0; i &lt; schoolBellTime.length-1; i++) {
    var startTime = schoolBellTime[i].split(":");
    var endTime = schoolBellTime[i+1].split(":");
  
    if (parseInt(startTime[0]) &gt;= date.getHours() &amp;&amp; parseInt(startTime[1]) &gt;= date.getMinutes())
     if (parseInt(endTime[0]) &lt;= date.getHours() &amp;&amp; parseInt(endTime[1]) &lt;= date.getMinutes()) {
      currentHour = i;
      remainingTime=(parseInt(endTime[1])-date.getMinutes()+60)%60;
      break;
     }
   }
  
    if (currentHour == undefined)
    return {current: -1, remaining: "not available"};
   return {current: currentHour, remaining: remainingTime};
  }
  
  var info = getInfoSchoolTime();
  console.log(info.current, info.remaining);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have the <code>schoolBellTime</code> array that contains the timestamps of my school bell (I know, my school has strange bell times, these timestamps includes playtimes and lunchtime), this function is meant to return the 1st hour/2nd hour/3rd hour ... and the minutes that remains to the next hour/breaktime.</p>
  
  <p>I checked all the code and can't find the error, it keeps returning <code>{current: -1, remaining: "not available"}</code></p>