Exercise Tracker Create Exercise

Tell us what’s happening:
I am having problem with adding exercise but the my printing all log test is ok and next one print selected log have also the problem

Your code so far

app.post('/api/exercise/add', function(req,res){
  const { userId, description, duration, date} = req.body;
  
  const dateObj = date === '' ? new Date() : new Date(date);
  if(!getUserNameById(userId)){
    return res.json("User Not found");
  }
  const newExercise= {
    _id : userId,
    username: getUserNameById(userId),
    date: dateObj.toString(),
    duration: +duration,
    description
    
}
  exercise.push(newExercise);
  res.json(newExercise);
});

app.get('/api/exercise/log',function(req,res){
  const { userId, from, to, limit } = req.query;
  const exe = getex(userId);
  let log = getex(userId);
  
  if(from){
    const fromDate = new Date(from);
    log = log.filter(exe => new Date(exe.date) > fromDate);
  }
  if(to){
    const fromDate = new Date(from);
    log = log.filter(exe => new Date(exe.date) < fromDate);
  }
  
  if(limit){
    log = log.slice(0, +limit)
  }
  
  res.json({
    _id:userId,
    username: getUserNameById(userId),
    count:log.length,
    log
  })
})

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

Hello there,

I have not gone over your full code, but you may want to use toDateString() as opposed to toString().

Let us know if that changes anything

Thank you so much it worked

I know its late but, what is the expected output of the test
You can POST to /api/exercise/add with form data userId=_id , description , duration , and optionally date . If no date is supplied, the current date will be used. The response returned will be the user object with the exercise fields added.

I just need that jesus