Timestamp microservice not passing in FCC's link

my code is passing all the test in my browser, yet its not passing in my repl and the FCC’s solution link.
3rd day ive been on this now… already tried different codes, same thing.

code:

 resObject = {};
app.get('/api/timestamp/:input', (req, res) => {
let input = req.params.input;

if(input.includes('-')){
  resObject['unix'] = new Date(input).getTime();
  resObject['utc'] = new Date(input).toUTCString();
}else{
  input = parseInt(input);
  resObject['unix'] = new Date(input).getTime();
  resObject['utc'] = new Date(input).toUTCString();
}

if(!resObject['unix'] || !resObject['utc']){
  res.json({error: "Invalid Date"})
}

res.json(resObject);
});

app.get('/api/timestamp', (req, res) => {
resObject['unix'] = new Date().getTime();
resObject['utc'] = new Date().toUTCString();

res.json(resObject);
})  

Hi @6ix-Ville !

Please post your code in the forum.

Here is how to post code in the forum

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor ( </> ) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

i cant believe ive been figuring it out myself (felt like a code guru, only lasted for one sec tho)
so now every other thing is passing except this code

resObject = {};
app.get('/api/:date_string', (req, res) => {
let date_string = req.params.date_string;

if(date_string.includes('-')){
  resObject['unix'] = new Date(date_string).getTime();

  resObject['utc'] = new Date(date_string).toUTCString();
}else{
  date_string = parseInt(date_string);
  
  resObject['unix'] = new Date(date_string).getTime();

  resObject['utc'] = new Date(date_string).toUTCString();
}

if(!resObject['unix'] || !resObject['utc']){
  res.json({error: "Invalid Date"})
}

res.json(resObject);
});

app.get('/api/', (req, res) => {
resObject['unix'] = new Date().getTime();
resObject['utc'] = new Date().toUTCString();

res.json(resObject);
});

except this part

Your project can handle dates that can be successfully parsed by new Date(date_string)

pls any help on how pass only this part?

passed it already…MYSELF…learnt a lot in ds process

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