Passing criteria is not clear!

What is your hint or solution suggestion?
The instruction for Exercise Tracker might need some work. There is no clear passing criteria, especially the 3rd one.A screen shot of what is expected would be nice.

Challenge: Exercise Tracker

Link to the challenge:

I’ve edited your post for readability. 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 (’).

Welcome, thomas.

It is difficult to debug your code, without a link to your project. Would you mind sharing it?

We are aware of the issue with clarity in this project, and fixes are on the way. I do recommend you take a look at the fCC repo where you can find/report issues with the platform/content.

Further, I recommend you take a look at the tests:

I realise this is not ideal, but we cannot help you more than you can help yourself.

Hope this is useful.

Pass!

Thank you for your prompt reply, and please find the code of my project. Sorry about the messy code, I tried to clean it up as much as possible. But I’m still new to this.

require('dotenv').config();
const express = require('express')
const app = express()
const bodyParser = require('body-parser')

app.use(bodyParser.urlencoded({extended: false}))
app.use(bodyParser.json())

const cors = require('cors')

const mongodb = require('mongodb')
const mongoose = require('mongoose')

const connect = mongoose.connect(process.env.mongoUrl, {useUnifiedTopology: true, useNewUrlParser: true
}, function(err){
  if(err){console.log(err)}
  mongoose.connection.db.dropDatabase();
  console.log('connected to db, and cleaned db')
});
mongoose.set('useCreateIndex', true);
console.log(mongoose.connection.readyState);

const userSchema = new mongoose.Schema({
  username: String
});
const exerciseSchema = new mongoose.Schema({
  username: {type: String, required: true},
  description: {type: String, required: true},
  duration: {type: Number,required: true},
  userId: {type: String,required: true,},
  date: {type: String,required: true,default: (new Date()).toDateString()}
})

const User = new mongoose.model('User', userSchema);
const Exercise = new mongoose.model('Exercise', exerciseSchema);

app.use(cors())

app.use(express.static('public'))
app.get('/', (req, res) => {
  res.sendFile(__dirname + '/views/index.html')
});

app.post('/api/exercise/new-user', (req, res)=>{
  const username = req.body.username;
  console.log(username);
  new User({
    username: username
  }).save((err, results)=>{
    if(err){
      console.log(err)
      } else{
      console.log(results);
      res.json({'username': results.username, '_id':results._id})
    }
  })
});

app.get('/api/exercise/users', async (req, res)=>{
 await User.find({}, (err, data)=>{
    if(err){
      console.log(err)
    } else{
      console.log(data)
      const arr = []
      data.forEach(obj=> arr.push(obj.username))
      res.json(arr)
    }
  })
})

app.post('/api/exercise/add', async(req, res)=>{
  const userId = req.body.userId
  const description = req.body.description
  const duration = req.body.duration
  const dateString = (new Date(req.body.date)).toDateString()
 
  await User.findOne({_id: userId}, (err, data)=>{
    if(err){
      console.log(err)
    } else{
        console.log(data)
        new Exercise({
        username: data.username,
        description: description,
        duration: parseInt(duration),
        userId: userId,
        date: dateString
      }).save((err, data)=>{
        if(err){
          console.log(err)
        } else{
          console.log(data);
          res.json({'_id':data.userId, 'username': data.username, 'date': data.date, 'duration': data.duration, 'description':data.description})
        }
      })
      }
    })
  });

app.get('/api/exercise/log', async (req, res)=>{
  try{
    const id = req.query.userId
    const from = req.query.from
    const to = req.query.to
    const limit = req.query.limit

    Exercise.find({userId: id}, ((err, data)=>{
      if (err){
        res.send(err)
      } 
        console.log(data)
        var log = data
        if(from && !to){
          log = log.filter(obj=> new Date(obj.date).getTime()> new Date(from).getTime());
        } else if (!from && to){
          log = log.filter(obj=> new Date(obj.date).getTime()< new Date(to).getTime());
        } else if (from && to){
          log = log.filter(obj=> new Date(obj.date).getTime()> new Date(from).getTime() && new Date(obj.date).getTime()< new Date(to).getTime());
        }

        if (limit){
          log = log.slice(0, parseInt(limit));
        }
        const count = log.length
        res.json({username: data[0].username, 'username': data[0].username, 'count': count, 'log': log})
    }))
  } catch(err){
    console.log(err)
  }
})
const listener = app.listen(process.env.PORT || 3000, () => {
  console.log('Your app is listening on port ' + listener.address().port)
})

It’s would be nice to show a response example, like the one attached. So we know what should we put in the log, and what else should we send back as response. That’s all it takes to fix my problem anyway.

Well done, on passing.

In the hints page, there should be an example output with a few hints. Perhaps we could improve this for now.

Anyway, keep it up.