-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleJS
More file actions
19 lines (18 loc) · 762 Bytes
/
Copy pathSampleJS
File metadata and controls
19 lines (18 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function calculateBilling() {
let basicServiceCost = 20; // R20 per month //consider the difference var / let
let premiumServiceCost = 30; // R30 per month
let CALLS = 100;
let MINUTES = 500;
let totalBill = 0;
const customerID = document.getElementById('customerID').value;
const callsMade = parseInt(document.getElementById('callsMade').value);
const callMinutes = parseInt(document.getElementById('callMinutes').value);
if(callsMade > CALLS) {
totalBill = basicServiceCost + (callMinutes * 0.5); // R0.50 per minute for extra calls
}
else {
totalBill = premiumServiceCost;
}
let output = "Customer ID: " + customerID + " Billing Total: R" + totalBill.toFixed(2);
document.getElementById('billingResult').innerHTML = output;
}