Currently, my code looks like this:
const weekdays = eachDay.map((day) => format(day, 'EEE'));
let ret = { Su: '', Mo: '', Tu: '', We: '', Th: '', Fr: '', Sa: '' };
weekdays.forEach((day, index) => {
ret[Object.keys(ret)[index] as DaysOfWeekMui] = day;
});
I was told by a fellow team member that I could improve this code by using a reduce
method instead of manually defining the object ret
. However, I'm not exactly sure how to do that. Any guidance on this issue would be greatly appreciated.
Thank you for your assistance.