I want to store two values in an object: today
, todayInOneYear
. I use a function to calculate the +1 year.
obj = {}
today = new Date();
obj = {
today: today,
oneYear: addOneYear(today)
}
console.log(obj)
function addOneYear(date) {
date.setFullYear(date.getFullYear() + 1);
return date;
}
Problem: Today and todayInOneYear are the same. But I expect two different dates. Once from now (today) and then once from a year from now. Do you know what I'm missing?