-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeater.html
More file actions
43 lines (35 loc) · 902 Bytes
/
theater.html
File metadata and controls
43 lines (35 loc) · 902 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Magical Mystery Theater</title>
</head>
<body>
<h1>Magical Mystery Theater</h1>
<button
type="button"
onclick="buyTicket()">
Purchase Ticket
</button>
<script>
const GENERAL_ADMISSION_TICKET_COST = 20;
const CHILD_AND_SENIOR_TICKET_COST = 10;
const MATINEE_DISCOUNT = 3;
function buyTicket() {
const age = prompt('What is your age?');
const isMatinee = prompt('Are you attending a matinee show?');
let cost = getBaseTicketCost(age);
if (isMatinee === 'yes' || isMatinee === 'y') {
cost = cost - MATINEE_DISCOUNT;
}
alert('Your ticket will cost: $' + cost);
}
function getBaseTicketCost(age) {
if (age <= 12 || age >= 65) {
return CHILD_AND_SENIOR_TICKET_COST;
}
return GENERAL_ADMISSION_TICKET_COST;
}
</script>
</body>
</html>