Is there a way to incorporate the value into my for loop so that both the key and value are displayed in my innerHTML? Your guidance is much appreciated!
<body>
<section>
<h2>Toppings</h2>
<ul id="toppings"> </ul>
</section>
</body>
<script>
var myObj ={"menu": {"slice of pizza": "2.00", "toppings": {"pepperoni": ".25","meatballs": ".35", "mushrooms": ".40","olives": ".20"},"sides": {"potato salad": "1.25","hummus": "2.50","caesar salad": "3.50","garden salad": "2.25"}, "drinks": { "soda": { "small": "1.95", "medium": "2.20","large": "2.50" }, "juice": "2.00", "water": "1.25"}}};
var extras ="";
for(key in myObj.menu.toppings){
if (myObj.menu.toppings.hasOwnProperty(key)) {
extras +='<li>' +
key + ': ' + myObj.menu.toppings[key] + '</li>';
}
}
var update = document.getElementById('toppings').innerHTML = extras;
</script>
</html>