Convert Date to ISO String

83.3% Acceptance

ISO 8601 Date Strings

A widely used standard for datetime representation is ISO 8601. ISO 8601 date strings come in several different formats, but the most common and recognized format is something like this: 2018-10-01T04:29:42.000Z. The toISOString() function provided in JavaScript is essential in converting dates into ISO 8601 strings.

In this lab, you'll create a function convertToISOString that accepts a Date object as a parameter and returns its ISO 8601 string representation. The function should handle error cases for undefined input or input that is not a Date object.