) How can i access the Soda object keys and values from this JSON string and get them to display in my innerHTML? What I have here displays the drinks but i need to also display the soda selection...thank you for your help!
<script>
var selection ='{"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 myObj = JSON.parse(selection)
var extras ="";
var key="";
var beverages ="";
for(key in myObj.menu.drinks){
if (myObj.menu.drinks.hasOwnProperty(key)) {
beverages +='<li>' +
key + ':' + myObj.menu.drinks[key] + '</li>';
}
}
var update = document.getElementById('drinks').innerHTML = beverages;
</script>