날짜를 가지고있는 객체를 담은 배열에서 가장 오래된 날짜를 추출해야한다.

// 가장 오래된 날짜 구하기
const oldestDate = stampData.map((list) => {
return list.created_at.reduce((oldest, current) => {
return current < oldest ? current : oldest;
});
});
console.log('oldestDate', oldestDate);
TypeError: list.created_at.reduce is not a function // 가장 오래된 날짜 구하기
const oldestDate =
stampData.reduce((oldest, current) => {
const oldestDate = new Date(oldest.created_at); //비교대상날짜
const currentDate = new Date(current.created_at); //비교할 기준점날짜
return currentDate < oldestDate ? current : oldest;
});
currentDate < oldestDateccurrent : oldesttrue : current가 가장 오래된 날짜false : oldest가 가장 오래된 날짜