-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_26.js
23 lines (21 loc) · 930 Bytes
/
program_26.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"use strict";
/*
* Alien Colors #2: Choose a color for an alien as you did in Exercise 25, and write an if-else chain.
• If the alien’s color is green, print a statement that the player just earned 5 points for shooting the alien.
• If the alien’s color isn’t green, print a statement that the player just earned 10 points.
• Write one version of this program that runs the if block and another that runs the else block.
*/
let alien_color2 = 'green'; // The alien is green
if (alien_color2 === 'green') {
console.log("The player just earned 5 points for shooting the alien"); // This will be printed
}
else {
console.log("The player just earned 10 points");
}
let alien_color3 = 'yellow'; // The alien is yellow
if (alien_color3 === 'green') {
console.log("The player just earned 5 points for shooting the alien");
}
else {
console.log("The player just earned 10 points"); // This will be printed
}