{"ScriptPreparationCode":"const daySlots = {\r\n calendar: {\r\n calendar_items: [{\r\n weekday_id: 1\r\n },\r\n {\r\n weekday_id: 3\r\n },\r\n {\r\n weekday_id: 5\r\n },\r\n ],\r\n date_range_days: 30,\r\n },\r\n};","TestCases":[{"Name":"Original Function","Code":"const getMarkedDates = () =\u003E {\r\n let markedDatesObj = {};\r\n let maxDate = null;\r\n\r\n if (daySlots \u0026\u0026 daySlots?.calendar?.calendar_items) {\r\n const daysOfWeek = [0, 1, 2, 3, 4, 5, 6];\r\n const workingDays = daySlots?.calendar?.calendar_items.map(\r\n item =\u003E item.weekday_id,\r\n );\r\n const disabledDays = daysOfWeek.filter(\r\n day =\u003E !workingDays.includes(day),\r\n );\r\n\r\n const currentDate = new Date();\r\n const lastDate = new Date(currentDate);\r\n lastDate.setDate(\r\n currentDate.getDate() \u002B daySlots?.calendar?.date_range_days,\r\n );\r\n maxDate = lastDate.toISOString().slice(0, 10);\r\n\r\n for (\r\n let d = new Date(currentDate);\r\n d \u003C= lastDate;\r\n d.setDate(d.getDate() \u002B 1)\r\n ) {\r\n const currentDay = d.getDay();\r\n if (disabledDays.includes(currentDay)) {\r\n const dateString = d.toISOString().slice(0, 10);\r\n markedDatesObj = {\r\n ...markedDatesObj,\r\n [dateString]: {\r\n disabled: true,\r\n disableTouchEvent: true,\r\n textColor: \u0027red\u0027,\r\n color: \u0027transparent\u0027,\r\n },\r\n };\r\n }\r\n }\r\n }\r\n return {markedDates: markedDatesObj, maxDate};\r\n };","IsDeferred":false},{"Name":"New Version","Code":"const getMarkedDates = () =\u003E {\r\n const markedDatesObj = {};\r\n let maxDate = null;\r\n\r\n if (daySlots?.calendar?.calendar_items) {\r\n const daysOfWeek = [0, 1, 2, 3, 4, 5, 6];\r\n const workingDays = daySlots.calendar.calendar_items.map(item =\u003E item.weekday_id);\r\n const disabledDays = daysOfWeek.filter(day =\u003E !workingDays.includes(day));\r\n\r\n const currentDate = new Date();\r\n const lastDate = new Date(currentDate);\r\n lastDate.setDate(currentDate.getDate() \u002B daySlots.calendar.date_range_days);\r\n maxDate = lastDate.toISOString().slice(0, 10);\r\n\r\n const iterateDate = new Date(currentDate);\r\n while (iterateDate \u003C= lastDate) {\r\n const currentDay = iterateDate.getDay();\r\n if (disabledDays.includes(currentDay)) {\r\n const dateString = iterateDate.toISOString().slice(0, 10);\r\n markedDatesObj[dateString] = {\r\n disabled: true,\r\n disableTouchEvent: true,\r\n textColor: \u0027red\u0027,\r\n color: \u0027transparent\u0027,\r\n };\r\n }\r\n iterateDate.setDate(iterateDate.getDate() \u002B 1);\r\n }\r\n }\r\n return { markedDates: markedDatesObj, maxDate };\r\n};\r\n","IsDeferred":false}]}