So, in this exercise they use dateObject.toString() === “Invalid Date” to make sure it is a valid date. I have a few question.
I tried to search on MDN’s documentation about the “Invalid Date” error. The idea is that I don’t know about the existence of it, so I want to get to the kind of error that is returned when there’s an invalid date (could be null ,undefined, or apparently anything else. So, I went to Date.prototype.toString() and Date MDN’s documentation. I could not find any reference about “Invalid Date”. So:
How am I supposed to find it by browsing if I don’t know about it’s existence?
Where is it the be found BY BROWSING MDN’S DOCUMENTATION?
Why does it take the form of a string(instead of null, undefined, etc)?
Why did they choose the dateObject.toString() method to validate the date on the resolution?
Which other method could have been used and why?
This is the web for the error itself, but it seems to be disconnected somehow from the Date documentation (can’t find a way to get by growsing from Date to the error page). And besides, it states that the error comes from Date or Date.parse(), but in the resolution they use dateObject.toString() to get the error, which seems unnecessary, or at least, arbitrary. Please, make any comment on this.
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36.
Challenge: Timestamp Microservice
Link to the challenge: