-- Apr 21 In-Class Exercise Thread
<!DOCTYPE html>
<html>
<head>
<title>inclass exercise</title>
<meta charset="utf-8"/>
</head>
<body>
<script>
function prettyPrint()
{
for(i = 0; i<this.groceries_prices[0].length; i++)
{
document.write(this.groceries_prices[0][i], ": ", this.groceries_prices[1][i], "
");
}
}
function Cart(groceries_prices)
{
this.groceries_prices = groceries_prices;
this.prettyPrint = prettyPrint;
}
arr = [["Tomato","Potato","Apple","Banana"],["$3","$5","$1","$2"]]
var cart = new Cart(arr);
cart.prettyPrint();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>inclass exercise</title>
<meta charset="utf-8"/>
</head>
<body>
<script>
function prettyPrint()
{
for(i = 0; i<this.groceries_prices[0].length; i++)
{
document.write(this.groceries_prices[0][i], ": ", this.groceries_prices[1][i], "<br />");
}
}
function Cart(groceries_prices)
{
this.groceries_prices = groceries_prices;
this.prettyPrint = prettyPrint;
}
arr = [["Tomato","Potato","Apple","Banana"],["$3","$5","$1","$2"]]
var cart = new Cart(arr);
cart.prettyPrint();
</script>
</body>
</html>