From 16aeb7672e288135f924a42aec125d52058ab07e Mon Sep 17 00:00:00 2001 From: ArachnidsGrip Date: Sat, 2 Mar 2019 15:41:55 +1000 Subject: [PATCH] Fix object bug Fix object handling so we don't just push array to name --- _steps/step14-new-recipes.markdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/_steps/step14-new-recipes.markdown b/_steps/step14-new-recipes.markdown index 86d6017..b4a94dc 100644 --- a/_steps/step14-new-recipes.markdown +++ b/_steps/step14-new-recipes.markdown @@ -25,8 +25,8 @@ So let's create our `getNextId` function in `recipesDB.js`: ```javascript function getNextId(){ - var recipeWithBiggestId = db.get('recipes').maxBy(function(recipe){ - return recipe.id; + var recipeWithBiggestId = db.get('recipes').maxBy(function(recipe){ + return recipe.id; }); return recipeWithBiggestId.value().id+1; } @@ -36,11 +36,11 @@ What this function does is ask the database what the recipe is with the largest Now that we have that, let's create our function to add new recipes to `recipesDB.js`: ```javascript -function addRecipe(name, content){ - var newRecipe = { - id: getNextId(), - name: name, - content: content +function addRecipe(recipe){ + var newRecipe = { + id: getNextId(), + name: recipe.name, + content: recipe.content }; db.get('recipes') .push(newRecipe)