{"ScriptPreparationCode":"let startDate = new Date();","TestCases":[{"Name":"Using Math","Code":"const getNextMonth = (startDate) =\u003E {\r\n let current;\r\n if (startDate.getMonth() == 11) {\r\n current = new Date(startDate.getFullYear() \u002B 1, 0, 1);\r\n } else {\r\n current = new Date(startDate.getFullYear(), startDate.getMonth() \u002B 1, 1);\r\n }\r\n\r\n return current.getMonth();\r\n};\r\n\r\nlet startDate = new Date();\r\ngetNextMonth(startDate);","IsDeferred":false},{"Name":"Using Date Object","Code":"const outputDate = (date, output = \u0027month\u0027) =\u003E {\r\n switch (output) {\r\n default:\r\n case \u0027month\u0027:\r\n return date.getMonth();\r\n case \u0027fulldate\u0027:\r\n return date;\r\n case \u0027year\u0027:\r\n return date.getFullYear();\r\n }\r\n};\r\n\r\nconst changeMonth = (current = new Date(), change) =\u003E {\r\n if (change === 0) return current;\r\n\r\n const unformatted = new Date(current).setMonth(current.getMonth() \u002B change);\r\n const formatted = new Date(unformatted);\r\n return formatted;\r\n};\r\n\r\nconst getNextMonth = (current = new Date(), output = \u0027month\u0027) =\u003E {\r\n const nextMonth = changeMonth(current, 1);\r\n return outputDate(nextMonth, output);\r\n};\r\n\r\nlet startDate = new Date();\r\ngetNextMonth(startDate)","IsDeferred":false},{"Name":"Small Date Object","Code":"const changeMonth = (current, change) =\u003E {\r\n if (change === 0) return current;\r\n\r\n const unformatted = new Date(current).setMonth(current.getMonth() \u002B change);\r\n return new Date(unformatted);\r\n};\r\n\r\nconst getNextMonth = (current) =\u003E {\r\n return changeMonth(current, 1).getMonth()\r\n};\r\n\r\nlet startDate = new Date();\r\ngetNextMonth(startDate)","IsDeferred":false},{"Name":"Even smaller Date Object","Code":"const getNextMonth = (current) =\u003E {\r\n const unformatted = new Date(current).setMonth(current.getMonth() \u002B 1)\r\n return new Date(unformatted).getMonth()\r\n};\r\n\r\nlet startDate = new Date();\r\ngetNextMonth(startDate)","IsDeferred":false}]}