Help, I am not able to pass this challenge

Create and Save a Record of a Model

At this challenge, my solution is not getting accepted. Not sure how the expected output looks like. Please suggest if I have missed anything for this challenge.

Code :

var Person = mongoose.model('Person', PersonSchema);

var person = new Person({
  name: 'Alex',
  age: 26,
  favoriteFoods: ['Donut'],
  dateOfBirth: '01/01/1995'
});

person.save((err, Person) => {
  if(err){
    console.log("There is an error");
  } else {
    console.log(person);
  }
});

I verified that the data is populated correctly in the db.

Link to the challenge:

Welcome, shashanksgowda.

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


The boilerplate should have some code like:

var createAndSavePerson = function(done) {

  
};

As well as comments telling you when and where to write.

Essentially, you should be using person.save within the given createAndSavePerson function, being sure to use the done callback.

Hope this helps

2 Likes