Currently, I am working on a function that aims to extract the first 14 consecutive days (starting from today) using momentJS. Here is what my current function looks like:
let dateArr = Array(14).fill(moment())
.map((date) => {
return date.add(1, 'days')
});
I've realized that fill
is suitable for static values, not dynamic ones. How can I modify this code so that it generates an array like this:
['11/12', '11/13', '11/14', etc...]
It seems like I may need to implement some form of recursion to ensure that each day is added sequentially based on the previous iteratee, rather than simply adding one day from the present date in every iteration.