banana: "1.99",
apple: "1.00",
bread: "3.99",
jelly: "4.99",
prettyPrint: function() {
for (prop in Cart){
if (prop != "prettyPrint"){
console.log(prop + ": " + Cart[prop]);
}
}
}
}
this.items = new Array("cookies","cereal", "pancake mix");
this.prices = new Array(1.25,2.50,3.75);
cart.prototype.display = function (){
for(i = 0; i < this.items.length;i++){
if(this.items[i] != "prettyPrint"){
console.log("Item: ", this.items[i]);
console.log("Price: ",this.prices[i]);
}
}
}
function cart()
{
this.beans = "3.50",
this.leeks = "4.44";
this.prettyPrint = function() {
for (stuff in this) {
if (stuff != "prettyPrint"){
document.write('<h1>' + stuff + ' ' + this[stuff] + '</h1>');
}
}
}
}
var myCart = new cart();
myCart.prettyPrint();
this.items = items;
this.price = price;
}
groceryCart = new cart(["milk", "cheese"], [2, 3]);
for (i = 0; i < groceryCart.items.length; i++)
{
console.log("Item: " + groceryCart.items[i] + " Price: $" + groceryCart.price[i]);
}
}
prettyPrint();
<script type="text/javascript">
var shoppingCart = new Object();
shoppingCart.ice_cream = 7;
shoppingCart.green_tea = 10;
shoppingCart.prettyPrint = function()
{
for(merch in shoppingCart)
{
if(merch != "prettyPrint")
{
document.write(merch +''+ shoppingCart[merch] + '
</br>');
}
}
}
var cart = new shoppingCart();
cart.prettyPrint();
</script>
</body>
prettyPrint:()=>{
for(item of items){
console.log("Name: ",item[0]," Price: ",item[1])
}
}}
}
var x=Cart(["milk",2],["banana",4],["apple",5])
x.prettyPrint()
console.log("Food: ", prop, " Price: ", groceryList[prop]);
}