-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ27.js
39 lines (39 loc) · 1.53 KB
/
Q27.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
"use strict";
// 27. 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.
// For Green: :~If You want to print only Green Color then comment remaining 2 colors
let alienColor = "Green";
if (alienColor === "Green") {
console.log("Player just earned 5 points!");
}
else if (alienColor === "Yellow") {
console.log("Player just earned 10 points!");
}
else if (alienColor === "Red") {
console.log("Player just earned 15 points!");
}
// For Yellow: :~If You want to print only Yellow Color then comment remaining 2 colors
let alienColor = "Yellow";
if (alienColor === "Green") {
console.log("Player just earned 5 points!");
}
else if (alienColor === "Yellow") {
console.log("Player just earned 10 points!");
}
else if (alienColor === "Red") {
console.log("Player just earned 15 points!");
}
// For Red: :~If You want to print only Red Color then comment remaining 2 colors
let alienColor = "Red";
if (alienColor === "Green") {
console.log("Player just earned 5 points!");
}
else if (alienColor === "Yellow") {
console.log("Player just earned 10 points!");
}
else if (alienColor === "Red") {
console.log("Player just earned 15 points!");
}