today,weekly I learn

24.7.29

rhdaud2 2024. 7. 30. 09:15

 

 

reduce() 를 이용해 날짜가 포함된 객체 요소를 가진 배열

날짜별로 분류하기

 

 

 

const ordersList = payHistoryList.reduce((acc: any, order: any) => {
    const date = dayjs(order.payment_date).format('YYYY-MM-DD');
    if (!acc[date]) {
      acc[date] = [];
    }
    acc[date].push(order);
    return acc;
  }, {});
  const sortedDates = Object.keys(ordersList).sort(
    (a, b) => Date.parse(b) - Date.parse(a)
  );

 

'today,weekly I learn' 카테고리의 다른 글

24.7.31  (0) 2024.07.31
24.7.30  (0) 2024.07.30
24.7.25  (0) 2024.07.25
24.7.24  (0) 2024.07.24
24.7.23  (1) 2024.07.23