[Vuejs]-Find max and min date from an array of date strings

0👍

I’ve not used moment.js before but from your code, I figure this is how it’s used to format dates

const max = moment(data.map(obj => new Date(obj.mas_plan_end ?? '')).reduce((a, b) => b > a ? b : a)).format("YYYY-MM-DD");
const min = moment(data.map(obj => new Date(obj.mas_plan_start ?? '')).reduce((a, b) => b < a ? b : a)).format("YYYY-MM-DD");

The ?? operator I used is called the nullish coalescing operator it returns the second value, if the first value is null or undefined. Nullish Coalescing MDN

Leave a comment