Why does this code not pass the 4th test for exercise tracker?

I got this working and it seems like it does everything it is supposed to. response.json looks the same as the example and the array is being saved in my mongodb atlas. Why is this not passing the test :frowning:

  let responseObject = {};
  responseObject["_id"] = req.body.userId;
  User.findById(req.body.userId, (err,data) => {
    if(err) return console.log(err);



    responseObject["username"] = data.username;
    console.log(req.body.date);
    let dateString = "";
    if(req.body.date === ""){
      dateString = new Date().toString();
    }else{
      dateString = new Date(req.body.date).toString();
    }
    dateString = dateString.split(' ').slice(0,4).join(' ');
    responseObject["date"] = dateString;
    responseObject["duration"] = req.body.duration;
    responseObject["description"] = req.body.description;



    data.log.push({description: req.body.description, duration: req.body.duration, date: responseObject.date.toString()});
    data.save();
    res.json(responseObject);
  }) 

})```

Open up Chrome developer console while running the tests.

Information regarding why the test is not passing should be logged on to the console.

If you could tell me, what error you are getting, I can be of better help.

1 Like

Hey I did not see this response. I ended up getting it working, the problem was that FCC wants the duration to be a number and I was giving it a string. Thank you for your help.

1 Like

my duration is already number, but i’m still stuck getting the 4th test

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