I am trying to create a for loop that generates the date for the next 5 days and prints them in an empty h6 element, but instead of generating 5 dates one time, it is generating 5 dates five times, as shown in the console log. (I know moment.js isn't recommended anymore, this is just for a project)
screenshot of the console log result
This is my code:
for (var x = 1; x <= 5; x++){
$(".future-date").text(moment().add([x], "d").format("(MM/DD/YYYY)"));
console.log($(".future-date").text());
}
The result is that all h6 elements display the 5th date.
It should look like this, with 5 consecutive dates
Instead, they are all showing the last date.
What am I missing?