Need help with new Date and checking for invalid date

I want to check if this is an invalid date. So when there is one, I can convert the unix into an integer. How can I do this? As far as I know new Date returns me an string when unix is passed but not the message “Invalid Date”

 let date = new Date(date_str)
  
  console.log("DATE: ", date_str, typeof date_str)
  
  if (date === "Invalid Date") {
    console.log("this is an invalid date")
  }

Challenge: Timestamp Microservice

Link to the challenge:

In your if statement, you’re comparing a date object with a string. Since you’re using strict equality, it will always return false.

Thank you, your answers helped me complete the timestamp project!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.