Api micro services challenge exercise tracker challenge

Tell us what’s happening:
I am stuck at creating a user by posting form…

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15.

Challenge: Exercise Tracker

Link to the challenge:

Hello there,

Could you please edit your post to include details. You have not asked a question or shown any code, so we have no idea how to help. Could you provide a link to your project as well?

The more information you provide, the more likely we will be able to help.

could you please explain this further. I t is difficult to code it right. " If no date supplied it will use current date. App will return the user object with the exercise fields added."

My code is :

const dateObj = date === '' ? new Date() : new Date(date);
const newExercise = {
  _id: userId,
  description,
  duration,
  date: dateObj.toString()
}

if(newExercise.date === '') {
  newExercise.date === new Date().toISOString().substring(0, 10)
}

exercises.push(newExercise);

res.json(newExercise)
    
});

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 (’).

I do not quite understand your logic here:

if(newExercise.date === '') {
  newExercise.date === new Date().toISOString().substring(0, 10)
}

When would newExercise.date ever be equal to ''? You already satisfy this with the first line of your code.