-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
16 lines (13 loc) · 729 Bytes
/
Copy pathscript.js
File metadata and controls
16 lines (13 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Tip Splitter Function
document.getElementById('container').onchange = function () {
var bill = Number(document.getElementById('billTotal').value);
var tipPercent = document.getElementById('tipInput').value;
var splitBill = document.getElementById('splitInput').value;
var tipValue = bill * (tipPercent / 100);
var newBillEach = (bill + tipValue) / splitBill;
var tipEach = tipValue / splitBill;
document.getElementById('tipOutPut').innerHTML = " " + tipPercent + "%";
document.getElementById('splitOutPut').innerHTML = " " + splitBill + " people";
document.getElementById('newBill').innerHTML = " $" + newBillEach.toFixed(2);
document.getElementById('tipAmount').innerHTML = " $" + tipEach.toFixed(2);
}