Skip to content

Commit a6c0620

Browse files
committed
shorten code
1 parent c0107ff commit a6c0620

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎Sprint-2/debug/recipe.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ const recipe = {
1414
// const recipeKeys = Object.keys(recipe)
1515
// // console.log(recipeKeys)
1616

17-
const recipeValues = Object.values(recipe);
18-
// ["bruschetta", 2, ["olive oil", "tomatoes", "salt", "pepper"]]
19-
20-
const ingredients = recipeValues.slice(-1)[0];
17+
const ingredients = recipe.ingredients;
2118
// ["olive oil","tomatoes","salt","pepper"]
2219

2320
//create a function to log line by line the elements of an array
@@ -26,5 +23,5 @@ function logItemised(items) {
2623
}
2724

2825
console.log(
29-
`${recipe.title} serves ${recipe.serves}${"\n"}ingredients:${"\n"}${logItemised(ingredients)}`
26+
`${recipe.title} serves ${recipe.serves}${"\n"}ingredients:${"\n"}${recipe.ingredients.join("\n")}`
3027
);

0 commit comments

Comments
 (0)