**Tell us what’s happening:
My 5th test case is not working . But when I manually check it works.
**Your code so far
app.get("/api/hello", function (req, res) {
res.json({greeting: ‘hello API’});
});
app.get("/api/timestamp",(req,res)=>{
res.json({ “unix”:new Date().getTime(),
“utc”:new Date().toUTCString()})
})
app.get("/api/timestamp/:date_string",(req,res)=>{
var date_string = req.params.date_string;
if(date_string[4]=="-"&&date_string[7])
{
res.json({
“unix”:new Date(date_string).getTime(),
“utc”:new Date(date_string).toUTCString()
})
}
else{
date_string = Number(date_string);
if(Number.isInteger(date_string)==true)
{
res.json({
“unix”:new Date(date_string).getTime(),
“utc”:new Date(date_string).toUTCString()
})
}
else {
res.json({“error”:“Invalid Date”})
}
};
})
Above is the main code
Here u can get the whole code:
Link to the challenge: