Struggling with the last two challenges for exercise project

Tell us what’s happening:
I’m struggling with the last two tests. For whatever reason, it doesn’t seem to be accepting the format of the date despite it being seemingly exactly what they asked for.

The date property of any object in the log array that is returned from GET /api/users/:id/logs should be a string… Use the dateString format of the Date API.

My response:

  username: 'fcc_test_16358184666',
  count: 2,
  _id: '61809be274adb8d8bcea3699',
  log: [ { description: 'test', duration: 60, date: 'Mon Jan 01 1990' } ]

As for the very last challenge, I tried the following:

app.get("/api/users/:_id/logs", async (req, res) => {
  const userId = req.params._id;
  const documentLimit = Number(req.query.limit) || 0;
  const from = req.query.from || new Date(0);
  const to = || new Date(;

  const userDocument = await User.findById(userId);

  const logDocument = await Log.find({
    username: userDocument.username,
    log: {
      $elemMatch: {
        date: {
          $gte: from, 
          $lte: to

  const logResponse = {
    username: userDocument.username,
    count: logDocument.count,
    _id: userId,
    log: logDocument.log.slice(0, documentLimit + 1)


But logDocument returns nothing, or undefined. Any help would be greatly appreciated!

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0

Challenge: Exercise Tracker

Link to the challenge:

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