MCPcopy Create free account
hub / github.com/AyushSaini00/60minuteJavaScript / update

Function update

Tip-Calculator/app.js:16–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14//Updating the UI
15
16function update(){
17 let billAmount = Number(billAmountElem.value); //string to number
18 let tipPercentage = tipInputElem.value;
19 let persons = splitInputElem.value;
20
21 let tipValue = (tipPercentage / 100) * billAmount;
22 let tipEach = tipValue / persons;
23 let totalEach = (billAmount + tipValue) / persons;
24 let billEach = billAmount / persons;
25
26 tipPercentageElem.innerHTML = `${tipPercentage}%`;
27 tipTotalElem.innerHTML = formatMoney(tipValue);
28 splitValueElem.innerHTML = formatSplit(persons);
29 totalPerPersonElem.innerHTML = formatMoney(totalEach);
30 billPerPersonElem.innerHTML = formatMoney(billEach);
31 tipPerPersonElem.innerHTML = formatMoney(tipEach);
32}
33//FORMATTING MONEY
34
35function formatMoney(value){

Callers

nothing calls this directly

Calls 2

formatMoneyFunction · 0.85
formatSplitFunction · 0.85

Tested by

no test coverage detected