Tell us what’s happening:
Describe your issue in detail here.
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Back End Development and APIs Projects - Timestamp Microservice
Link to the challenge:
Hi everyone, I am trying to solve the timestamp project in Replit. The code works fine, it does everything it has to do but freeCodeCamp does not approve these items:
Even if this works, it is a questionable use of coercion. Check for what the Date constructor actually returns when provided with undefined or just a truthy check when applicable. I would also call the Date constructor before the logic and save the return, then reuse that value in the rest of the code. There is no need to keep calling the constructor.
if (new Date(inputDate) > 0)
Typo
inputDatee = parseInt(inputDate);
This else is when req.params.date is undefined. How can you use inputDate here? This is the case for the current time.
else {
inputDatee = parseInt(inputDate);
answerObj["unix"] = new Date(inputDate).getTime();
answerObj["utc"] = new Date(inputDate).toUTCString();
}
Thank you very much for your help. After changing the code and testing the live view several times I realized that the problem could be the time zone in which I am, which is different from the one that accepts the project as correct. To fix it, I changed the time on my computer so I could approve the project.