Exercise Tracker: Failing Test 7

I can post a new exercise to an existing id but it doesn’t display when I try to get the logs. Additionally, when i check in MongoDB database there isn’t the entry for the added exercise. So, i can start a new user, add an exercise but then can’t add an additional exercise.

Your project link(s)

solution: https://replit.com/@joetags/boilerplate-project-exercisetracker

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

Line 141 =>  info.save((error, data) => {

This could be the problem. You need to start with capitals.

It’s saved to a variable though. On the previous line.

info.save((error, data) => {
if (err) console.log(err)

You could try to debug.

I think there are a few issues here. You are defining Person with two fields–name and log. But you are not adding anything to this log when a new exercise is added. So the log array of a person remains empty (actually, you didn’t initialize to empty array so not sure Mongo will initialize it to or null). Since you’re storing everything in the exercise collection, you actually don’t need the log array in the Person model. Also, I noticed that you comment out the toDateString when returning a log of exercises. Why? You definitely need one. I passed the tests by converting the date using toDateString.

BTW, I define just one model, a Person with username: String and exercises:[{description:String, duration: Number, date: Date}].

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