javascript calculation not calculating
<p>Basically, I need to fix this script, I tried to fix it, but it returns -1 of days.
You can see the new script here -</p>

<pre><code>function calculatePrice(startDate, endDate, bike) {                           
    if(cars != "no") {
      console.log(startDate);
      console.log(endDate);
      var currentSeason = getSeason(startDate);
      var totalPrice = 0;
      var daysInSeason = 0;
      var currentDate = startDate;         
      var tierss = "";     
      var now = startDate;           
      var daye = 0;
      while(now &lt;= endDate) {
        var season = getSeason(currentDate);
        daye++;
        now.setDate(now.getDate() + 1);    
      }
      if(daye &lt;= 3) tierss = "t1";
      else if (daye &lt;= 8) tierss = "t2";
      else tierss = "t3"                                    
      while (currentDate &lt;= endDate) {                     
          var season = getSeason(currentDate);
          if (season != currentSeason) {
              totalPrice += getPrice(bike, currentSeason, daysInSeason, tierss);
              currentSeason = season;
              daysInSeason = 0;
          }
          daysInSeason++;
          console.log('days in season - ' + daysInSeason);
          currentDate.setDate(currentDate.getDate() + 1);
      }                                                
      totalPrice += getPrice(bike, currentSeason, daysInSeason, tierss);
      return totalPrice;
    }
    else {
      totalPrice = 0;
      return totalPrice;
    }
}
</code></pre>

<p>which returns -1 and this is the script which returns everything just fine - </p>

<pre><code>function calculatePrice(startDate, endDate, bike) {                           
  if(cars != "no") {
    console.log(startDate);
    console.log(endDate);
    var currentSeason = getSeason(startDate);
    var totalPrice = 0;
    var daysInSeason = 0;
    var currentDate = startDate;
    while (currentDate &lt;= endDate) {
        var season = getSeason(currentDate);
        if (season != currentSeason) {
            totalPrice += getPrice(bike, currentSeason, daysInSeason);
            currentSeason = season;
            daysInSeason = 0;
        }
        daysInSeason++;
        currentDate.setDate(currentDate.getDate() + 1);
    }
    totalPrice += getPrice(bike, currentSeason, daysInSeason);
    return totalPrice;
  }
  else {
    totalPrice = 0;
    return totalPrice;
  }
}
</code></pre>

<p>Why I need to edit the script? Simply, because it returns days in current season, but I need to inclue in totalPrice total days and days in current season. Or another possibility is that I need to include the tier in getprice, as shown above, both should work.</p>

<p>Hope to hear help :)!</p>
