Perform Classic Updates by Running Find, Edit, then Save

I am trying to solve this challenge of finding, editing and updating.

var findEditThenSave = function(personId, done) {
  var foodToAdd = "hamburger";
  
  Person.findByIdAndUpdate({_id : personId}, {favoriteFoods: foodToAdd}, function(err, obj){
    if(err)
        console.log(err);
    done(null, obj);
  })
  
};

but i am not sure how to update the array and add the hamburger to existing array.
Can anybody help me with it.

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.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums