treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Will anyone be kind enough to explain this code to me?

  • Hello,

    I have a Javascript script here which i cant really make much sense off. Would anyone be kind enough to explain to me?

    Your help is greatly appreciated!

      function daysTilDate(expiredate){
    
      expiredate = expiredate.substr(6,4)+", "+expiredate.substr(3,2)+", "+(expiredate.substr(0,2));
    
      var thisDay=new Date(expiredate);
    
      var CurrentDate = new Date();
    
      var thisYear=CurrentDate.getFullYear();
    
      thisDay.getFullYear(thisYear);
    
      var DayCount=(thisDay-CurrentDate)/(1000*60*60*24);
    
      DayCount=Math.round(DayCount);
    
      return DayCount;
    }