-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic-operator.js
More file actions
26 lines (20 loc) · 836 Bytes
/
Copy patharithmetic-operator.js
File metadata and controls
26 lines (20 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Create a variable for the subtotal and make a calculation
var subtotal = (13 + 1) * 5; // Subtotal is 70
// Create a variable for the shipping and make a calculation
var shipping = 0.5 * (13 + 1); // Shipping is 7
// Create the total by combining the subtotal and shipping values
var total = subtotal + shipping; // Total is 77
// Write the results to the screen
var elSub = document.getElementById('subtotal');
elSub.textContent = subtotal;
var elShip = document.getElementById('shipping');
elShip.textContent = shipping;
var elTotal = document.getElementById('total');
elTotal.textContent = total;
/*
NOTE: textContent does not work in IE8 or earlier
You can use innerHTML on lines 12, 15, and 18 but note the security issues on p228-231
elSub.innerHTML = subtotal;
elShip.innerHTML = shipping;
elTotal.innerHTML = total;
*/