Question: In JavaScript. How to format this JavaScript object: let recipe = { ingredients: [ { name: 'Chicken', unit: 'Tsp', amount: 5 }, { name: 'Beans',

In JavaScript. How to format this JavaScript object:

let recipe = { ingredients: [ { name: 'Chicken', unit: 'Tsp', amount: 5 }, { name: 'Beans', unit: 'Liter', amount: 9 } ], name: 'Deconstructed Chicken with Beans', preptime: '22', cooktime: '4', description: 'A tasty recipe using Chicken and Beans' }

into this:

let recipe = { 0: { ingredients: [ { name: 'Chicken', unit: 'Tsp', amount: 5 }, { name: 'Beans', unit: 'Liter', amount: 9 } ], name: 'Chicken with Beans', preptime: '22', cooktime: '4', description: 'A tasty recipe using Chicken and Beans, id: 0 }, 1: { ingredients: [ { name: Beef, unit: 'Tsp', amount: 5 }, { name: 'Beans', unit: 'Liter', amount: 9 } ], name: Beef with Beans', preptime: '22', cooktime: '4', description: 'A tasty recipe using Beef and Beans, id: 1 } }

where the bolded increments when a new recipe is added.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!