-
Notifications
You must be signed in to change notification settings - Fork 18
/
38-round-trip.js
58 lines (51 loc) · 1.34 KB
/
38-round-trip.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Round Trip ✈️
// Codédex
const departTripTicket = {
name: "Brandon",
from: "Pittsburgh, PA",
to: "Augsburg, Germany",
businessClass: false,
upgrade() {
if (departTripTicket.businessClass) {
console.log("Your ticket is already business class!");
} else {
departTripTicket.businessClass = true;
}
}
};
const returnTripTicket = {
name: "Brandon",
from: "Augsburg, Germany",
to: "Pittsburgh, PA",
businessClass: true,
upgrade() {
if (returnTripTicket.businessClass) {
console.log("Your ticket is already business class!");
} else {
returnTripTicket.businessClass = true;
}
}
};
departTripTicket.upgrade();
returnTripTicket.upgrade();
// Bonus Section
departTripTicket.leaveTime = 12;
departTripTicket.arriveTime = 23;
departTripTicket.flightTime = function() {
let flightTime = departTripTicket.arriveTime - departTripTicket.leaveTime;
if (flightTime < 0) {
flightTime = flightTime * -1;
}
console.log(flightTime + " hours");
};
returnTripTicket.leaveTime = 24;
returnTripTicket.arriveTime = 4;
returnTripTicket.flightTime = function() {
let flightTime = returnTripTicket.arriveTime - returnTripTicket.leaveTime;
if (flightTime < 0) {
flightTime = flightTime * -1;
}
console.log(flightTime + " hours");
};
departTripTicket.flightTime();
returnTripTicket.flightTime();