Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
</body>
</html>
 
(function () {
  'use strict';
  
  function getLastDayOfQuarter(date) {
    var year = date.getFullYear();
    return [[3, 31], [6, 30], [9, 30], [12, 31]]
      .map(function (dates) {
        return new Date(year, dates[0] - 1, dates[1]);
      })
      .filter(function (endDate) {
        return date <= endDate;
      })[0];
  }
  
  var endOfQuarter = getLastDayOfQuarter(new Date());
  console.log(endOfQuarter.toDateString());
})();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers