how to make a grocery list in javascript

Solutions on MaxInterview for how to make a grocery list in javascript by the best coders in the world

showing results for - "how to make a grocery list in javascript"
Gaia
24 May 2018
1<!DOCTYPE html>
2<html>
3<head>
4<script>
5function getit(){
6    var result = document.getElementById('demo');
7        var allitems = 0;
8            var itemCount = prompt("how many items do you need?");
9                var items = {};
10for (i = 0; i < itemCount; i++) {
11items[i] = {
12
13    name : prompt("Product Name"), 
14    price : prompt("Product Price"), 
15    qty : prompt("Product qty")
16
17    }
18}
19
20for (i = 0; i < itemCount; i++) {
21var subtotal = 0;
22var total = 0;
23subtotal = items[i].price * items[i].qty;
24total = subtotal * 1.05;
25allitems = allitems + subtotal; 
26result.innerHTML += "Product: " + items[i].name + "<br/>";
27result.innerHTML += "Total Qty: " +items[i].qty + "<br/>";
28result.innerHTML += "Sub total: " + subtotal + "<br/>";
29result.innerHTML += "Sub total: " + total + "<br/>";
30if(i == (itemCount - 1)){result.innerHTML += "Sub total for all items: " + allitems + "<br/>";}
31}
32    }
33</script>
34    </head>
35<body>
36<button onclick="getit()">Shop</button>
37<p id="result">Creating a JavaScript Object.</p>
38
39
40
41</body>
42</html>
Joleen
12 May 2017
1sampoo 
2shope