Here is my Code. My question is how can I show the next month when my current month is Dec.
var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'];
console.log(monthNames[new Date().getMonth()].toString().substr(0, 3) + '-' + new Date().getFullYear().toString().substr(-2));
console.log(monthNames[new Date().getMonth()+1].toString().substr(0, 3) + '-' + new Date().getFullYear().toString().substr(-2));
console.log(monthNames[new Date().getMonth()+2].toString().substr(0, 3) + '-' + new Date().getFullYear().toString().substr(-2));
console.log(monthNames[new Date().getMonth()+3].toString().substr(0, 3) + '-' + new Date().getFullYear().toString().substr(-2));
console.log('Suppose if the current month is Dec-19 then what should I do? It should return next line as Jan-20 but it is not doing so');
This is my JSFIDDLE Fiddle
If my month is Dec 17 or Dec 18 how can I show the next month ? I need a vanilla JS solution, no jQuery, no lodash, no 3rd party libraries.