()
| 14 | //Updating the UI |
| 15 | |
| 16 | function 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 | |
| 35 | function formatMoney(value){ |
nothing calls this directly
no test coverage detected