-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion26.ts
38 lines (29 loc) · 1.7 KB
/
question26.ts
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
// Alien Colors #3: Turn your if-else chain from Exercise 5-4 into an if-else chain.
// • If the alien is green, print a message that the player earned 5 points.
// • If the alien is yellow, print a message that the player earned 10 points.
// • If the alien is red, print a message that the player earned 15 points.
// • Write three versions of this program, making sure each message is printed for the appropriate color alien.
let alienColor1: string = "green";
if (alienColor1 === "green") {
console.log("Congratulations! You just earned 5 points for shooting the green alien.");
} else if (alienColor1 === "yellow") {
console.log("Congratulations! You just earned 10 points for shooting the yellow alien.");
} else if (alienColor1 === "red") {
console.log("Congratulations! You just earned 15 points for shooting the red alien.");
}
let alienColor2: string = "yellow";
if (alienColor2 === "green") {
console.log("Congratulations! You just earned 5 points for shooting the green alien.");
} else if (alienColor2 === "yellow") {
console.log("Congratulations! You just earned 10 points for shooting the yellow alien.");
} else if (alienColor2 === "red") {
console.log("Congratulations! You just earned 15 points for shooting the red alien.");
}
let alienColor3: string = "red";
if (alienColor3 === "green") {
console.log("Congratulations! You just earned 5 points for shooting the green alien.");
} else if (alienColor3 === "yellow") {
console.log("Congratulations! You just earned 10 points for shooting the yellow alien.");
} else if (alienColor3 === "red") {
console.log("Congratulations! You just earned 15 points for shooting the red alien.");
}