Ayechan_San Ayechan_San - 6 months ago 10
HTML Question

Getting value out of a key. JavaScript

recipes: {
"Cupcakes": {name: "Cupcakes", available: true, ingredients: "", directions: ""},
"Cookies": {name: "Cookies", available: false, ingredients: "", directions: ""},
"Sushi": {name: "Sushi", available: true, ingredients: "", directions: ""},
"Apple_Pie": {name: "Apple_Pie", available: true, ingredients: "", directions: ""}
},


How can I get the ingredients out of the key "Sushi"?

Answer

You can access it like this:

var ingredients = recipes.Sushi.ingredients;