how to make a grocery list in javascript
JavaScript
<!DOCTYPE html>
<html>
<head>
<script>
function getit(){
var result = document.getElementById('demo');
var allitems = 0;
var itemCount = prompt("how many items do you need?");
var items = {};
for (i = 0; i < itemCount; i++) {
items[i] = {
name : prompt("Product Name"),
price : prompt("Product Price"),
qty : prompt("Product qty")
}
}
for (i = 0; i < itemCount; i++) {
var subtotal = 0;
var total = 0;
subtotal = items[i].price * items[i].qty;
total = subtotal * 1.05;
allitems = allitems + subtotal;
result.innerHTML += "Product: " + items[i].name + "<br/>";
result.innerHTML += "Total Qty: " +items[i].qty + "<br/>";
result.innerHTML += "Sub total: " + subtotal + "<br/>";
result.innerHTML += "Sub total: " + total + "<br/>";
if(i == (itemCount - 1)){result.innerHTML += "Sub total for all items: " + allitems + "<br/>";}
}
}
</script>
</head>
<body>
<button onclick="getit()">Shop</button>
<p id="result">Creating a JavaScript Object.</p>
</body>
</html>
Also in JavaScript:
- Title
- javascript array remove element
- Category
- JavaScript
- Title
- get current directory vbscript
- Category
- JavaScript
- Title
- angular rebuild
- Category
- JavaScript
- Title
- adding cors parameters to extjs ajax
- Category
- JavaScript
- Title
- calling function from function object javascript
- Category
- JavaScript
- Title
- filter javascript array
- Category
- JavaScript
- Title
- array data structure javascipt interview questions
- Category
- JavaScript
- Title
- check window resize javascript
- Category
- JavaScript
- Title
- flowjs attributes
- Category
- JavaScript
- Title
- icon shwoing a box react native vector icons
- Category
- JavaScript
- Title
- Factorial
- Category
- JavaScript
- Title
- convert json to object jackson
- Category
- JavaScript
- Title
- How to get the path to the file that required your module?
- Category
- JavaScript
- Title
- create react component class
- Category
- JavaScript
- Title
- forever loop in js
- Category
- JavaScript
- Title
- import dropdown react
- Category
- JavaScript
- Title
- emmet jsx visual studio
- Category
- JavaScript
- Title
- how to display image in html from json object
- Category
- JavaScript
- Title
- angular reactive forms
- Category
- JavaScript
- Title
- how to paste in input field react native
- Category
- JavaScript
- Title
- how to add property to object in javascript
- Category
- JavaScript
- Title
- async iife
- Category
- JavaScript
- Title
- import axios react
- Category
- JavaScript
- Title
- angular list contains property
- Category
- JavaScript
- Title
- iterate array in javascrpt
- Category
- JavaScript
- Title
- angular run with proxy
- Category
- JavaScript
- Title
- how to add validator to formgroup
- Category
- JavaScript
- Title
- default pool size in sequelize
- Category
- JavaScript
- Title
- count occurrences of character in string javascript
- Category
- JavaScript
- Title
- first element of array js
- Category
- JavaScript
- Title
- how to get a user input in js
- Category
- JavaScript
- Title
- after click text editior open in javascript
- Category
- JavaScript
- Title
- how to version a react app azure pipelines
- Category
- JavaScript
- Title
- how to manage a db connection in javascript
- Category
- JavaScript
- Title
- integer to array javascript
- Category
- JavaScript
- Title
- await async sleep
- Category
- JavaScript
- Title
- how to create seeds in sequelise
- Category
- JavaScript
- Title
- bootstrap modal remove gray background
- Category
- JavaScript
- Title
- how to map over arrays vuejs
- Category
- JavaScript
- Title
- how to initialize an array in javascript
- Category
- JavaScript
- Title
- .push js
- Category
- JavaScript
- Title
- angular router return back
- Category
- JavaScript
- Title
- get the id of a div in jquery
- Category
- JavaScript
- Title
- if back react
- Category
- JavaScript
- Title
- how to assign same value of a key to 2 different keys in output JSON jolt
- Category
- JavaScript
- Title
- convert date to string javascript
- Category
- JavaScript
- Title
- javascript array pop
- Category
- JavaScript
- Title
- boucle for of javascript
- Category
- JavaScript
- Title
- clear the console while in strict mode
- Category
- JavaScript
- Title
- command to start api on react
- Category
- JavaScript
- Title
- alternate color to table row jquery
- Category
- JavaScript
- Title
- how to remove duplicate array object in javascript
- Category
- JavaScript
- Title
- how to javascript
- Category
- JavaScript
- Title
- get utc time javascript
- Category
- JavaScript
- Title
- eval in js
- Category
- JavaScript
- Title
- how to import jquery in js file
- Category
- JavaScript
- Title
- express bodyparser deprecated
- Category
- JavaScript
- Title
- add variable numerically in javascript
- Category
- JavaScript
- Title
- add dynamic value to id attribute in angular 8
- Category
- JavaScript
- Title
- getFullYear within moment in angular
- Category
- JavaScript
- Title
- declare multiple variables javascript
- Category
- JavaScript
- Title
- javascript array concat spread operator
- Category
- JavaScript
- Title
- ionic react use yarn
- Category
- JavaScript
- Title
- array to comma separated list js
- Category
- JavaScript
- Title
- how to remove session data on tab close in redux\
- Category
- JavaScript
- Title
- how to make a vowel counter in javascript
- Category
- JavaScript
- Title
- express fingerprint
- Category
- JavaScript
- Title
- empty div jquery
- Category
- JavaScript
- Title
- chart.js label word wrap
- Category
- JavaScript
- Title
- email regex javascript
- Category
- JavaScript
- Title
- how to empty form after submit react
- Category
- JavaScript
- Title
- como ler um arquivo json com javascript
- Category
- JavaScript
- Title
- how to return a string x amount in javascript without using . repeat
- Category
- JavaScript
- Title
- angular submit form programmatically
- Category
- JavaScript
- Title
- Find the stray number
- Category
- JavaScript
- Title
- bootstrap javascript cdn
- Category
- JavaScript
- Title
- ES6: Use class Syntax to Define a Constructor Function
- Category
- JavaScript
- Title
- how to make ajax request javascript
- Category
- JavaScript
- Title
- how to turn decimales into percents with javascript
- Category
- JavaScript
- Title
- express json body
- Category
- JavaScript
- Title
- bootstrap js cdn
- Category
- JavaScript
- Title
- how to get data from localstorage in javascript
- Category
- JavaScript
- Title
- how the concat function works javascript
- Category
- JavaScript
- Title
- 404 json laravel
- Category
- JavaScript
- Title
- how to make a factorial function in javascript
- Category
- JavaScript
- Title
- how to add two number using jqueryu
- Category
- JavaScript
- Title
- how to use custom stylesheets express node
- Category
- JavaScript
- Title
- javascript call function every second
- Category
- JavaScript
- Title
- javascript access php variable
- Category
- JavaScript
- Title
- discord js get badge user
- Category
- JavaScript
- Title
- download image in nodejs
- Category
- JavaScript
- Title
- how to call javascript method using selectlist on change in vf page
- Category
- JavaScript
- Title
- how to add border to a text in html with javascript
- Category
- JavaScript
- Title
- how to display date in javascript
- Category
- JavaScript
- Title
- angular.min.js version
- Category
- JavaScript
- Title
- contact form7 404 wp-json feedback
- Category
- JavaScript
- Title
- import json file javascript
- Category
- JavaScript
- Title
- getboundingclientrect() javascript
- Category
- JavaScript
- Title
- empty textarea using jquery
- Category
- JavaScript
- Title
- how to Write a program that simulates a coin toss using random method of Javascript Math class
- Category
- JavaScript