Javascript Date Question 1

Introduction

We would like to calculate the date 12 months from now.

Using the Date type, calculate the date 12 months from now.

let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 

let nowDate = new Date(); 

console.log("Date 12 months ahead is " + //your code); 


let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 

let nowDate = new Date(); 

nowDate.setMonth(nowDate.getMonth() + 12); 
console.log("Date 12 months ahead is " + nowDate.getDate()); 
console.log(" " + months[nowDate.getMonth()]); 
console.log(" " + nowDate.getFullYear()); 



PreviousNext

Related