Reputation: 353
I got a array of days like this date = [22,25,30]
.
i can pass the date for each item like below which works fine.
But i wanted to pass the date dynamically to the this.highlightDays
instead of doing it one by one.
How can i do it ? Please help
this.highlightDays = [
{date: moment().date(22).valueOf()},
{date: moment().date(25).valueOf()},
{date: moment().date(30).valueOf()}
];
Upvotes: 1
Views: 48
Reputation: 7916
const dates = [22, 25, 30];
this.highlightDays = dates.map((date) => ({
date: moment().date(date).valueOf(),
}));
console.log(this.highlightDays);
<script src="https://momentjs.com/downloads/moment.js"></script>
Upvotes: 4