Skip to content

Instantly share code, notes, and snippets.

@abrarShariar
Created March 13, 2018 11:27
Show Gist options
  • Save abrarShariar/97e799bcfae348c52d6a9166090807ba to your computer and use it in GitHub Desktop.
Save abrarShariar/97e799bcfae348c52d6a9166090807ba to your computer and use it in GitHub Desktop.
month generator
const month = new Array();
month[0] = "Jan";
month[1] = "Feb";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "Aug";
month[8] = "Sep";
month[9] = "Oct";
month[10] = "Nov";
month[11] = "Dec";
const result = [];
const yearArr = ['2017', '2018'];
for(let i=0;i<yearArr.length;i++){
for(let j=1;j<=12;j++){
const startDate = new Date(`${yearArr[i]},${j},1`);
result.push(`${month[startDate.getMonth()]} ${startDate.getFullYear()}`);
}
}
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment