I'm trying to get max day in an array of dates but it returns Invalid Date or null.
Can't figure out what is wrong. Should I convert the values to another format?
Any help will be appreciated.
const dates=[
'2022-10-13T00:00:00.000',
'2023-10-14T00:00:00.000',
'2024-10-15T00:00:00.000',
'2020-10-16T00:00:00.000',
'2015-10-17T00:00:00.000',
'2028-10-18T00:00:00.000',
'2010-10-19T00:00:00.000',
]
//const maxDate=new Date(Math.max.apply(null,dates));
const maxDate=new Date(
Math.max(
...dates
),
)
console.log('maxDate', maxDate)