I am trying to create an Array of Years. Current year and Last Year. The following code is working however I wanted to see if there is a cleaner way of doing this?
var d = new Date(); var currentYear = (d.getFullYear()); var lastYear = (d.getFullYear() - 1); $scope.years = [ currentYear, lastYear ];
Advertisement
Answer
Try this
var d = new Date(); var currentYear = d.getFullYear(); var lastYear = currentYear - 1; $scope.years = [currentYear,lastYear];