Timestap Challange

The new Date() challangenge doent work can someone give me an opinion

Your project link(s)

solution: https://replit.com/@angelplaiesu/boilerplate-project-timestamp-1

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

Challenge: Timestamp Microservice

Link to the challenge:

This is the date used by the test 05 October 2011 make sure your regex handles spaces.

Another option is to use includes and check for - and ' '.

thats not the problem
its the new Date(data_sting) not wokring

It is the problem. Your regex makes your if statement condition false for the date I posted which is what is tested against.

const date = '05 October 2011'
const regex = /\d\d\d\d-\d\d-\d\d/g;

console.log(regex.test(date)); // false

Your code:

if (regex.test(req.rawdatepara)) {
  req.date = new Date(req.rawdatepara);
} else {
  let date = new Date(req.rawdatepara * 1).toUTCString();
  req.date = new Date(date);
}

When I fix that in your code I pass all the tests. I just used includes but you can use a regex as well.

Thank you it works now, i used the includes solution

1 Like

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