JSFiddle - React, Tailwind, and code Playground
by Alex Azuero
JavaScript
var items = ["eggs", "milk","magazine", "chocolate"];
for (var i=0; i < items.length; i++) {
alert(items[i]);
//alert(itemCost);
};
var total = 0;
var itemsPrices = {
eggs: 0.98,
milk: 1.23,
magazine: 4.99,
chocolate: 0.45
};
for ( var i in itemsPrices){
total+=itemsPrices[i];
};
alert(total);