Exercise Tracker - Test 4

Tell us what’s happening:

Hi Guys! I have a big issue with this project. My solution is almost perfect :smile: but it doesn’t pass test number four. I have tried all afternoon, without results.
My output for that request is the same as the example, I don’t understand what’s wrong.

My Project

{"_id":"606b82b3ae96280b457f1531","username":"s","date":"Mon Apr 05 2021","duration":30,"description":"test"}

Sample Project

{"_id":"606b82e00adc1c061c807e9a","username":"ciaone1234","date":"Mon Apr 05 2021","duration":30,"description":"test"}

Your project link(s)

solution: https://boilerplate-project-exercisetracker-1.ahivelasquez.repl.co

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0.

Challenge: Exercise Tracker

Link to the challenge:

Hello there,

I have just skimmed your code. So, this might not be the issue, but this logic for the date seems off:

const createAndSaveExercise = async (data) => {
  const user = await User.findById(data.userId);
  if (!data.date) data.date = new Date();
  const newExercise = new Exercise(data)
  const result = await newExercise.save();
  let d = new Date(result.date)
  let dString = d.toDateString();

  let utente = {
    _id: mongoose.Types.ObjectId(result._id),
    username: user.username, 
    date: dString,
    duration: result.duration, 
    description: result.description, 
  console.log("Save User", utente)
  return utente;
  • If there is a date, you do nothing with it (just save it)
  • I could pass anything into the date section

Essentially, does this log return look correct to you:

{"_id":"606c1e52c5f2000037d1e4d7","username":"shaun-test-user","__v":0,"count":1,"log":[{"_id":"606c1e72c5f2000037d1e4d8","userId":"606c1e52c5f2000037d1e4d7","description":"Test description","duration":100,"date":"2021-01-01T00:00:00.000Z","__v":0}]}

Hope this helps