-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMurder Mistry
61 lines (49 loc) · 2.04 KB
/
Murder Mistry
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
59
60
61
/*
In this murder mystery there are:
four rooms: the ballroom, gallery, billiards room, and dining room,
four weapons: poison, a trophy, a pool stick, and a knife,
and four suspects: Mr. Parkes, Ms. Van Cleve, Mrs. Sparr, and Mr. Kalehoff.
We also know that each weapon corresponds to a particular room, so...
the poison belongs to the ballroom,
the trophy belongs to the gallery,
the pool stick belongs to the billiards room,
and the knife belongs to the dining room.
And we know that each suspect was located in a specific room at the time of the murder.
Mr. Parkes was located in the dining room.
Ms. Van Cleve was located in the gallery.
Mrs. Sparr was located in the billiards room.
Mr. Kalehoff was located in the ballroom.
To help solve this mystery, write a combination of conditional statements that:
sets the value of weapon based on the room and
sets the value of solved to true if the value of room matches the suspect's room
Afterwards, print the following to the console if the mystery was solved:
__________ did it in the __________ with the __________!
Fill in the blanks with the name of the suspect, the room, and the weapon. For example,
Mr. Parkes did it in the dining room with the knife!
TIP: Make sure to test your code with different values. For example,
If room equals gallery and suspect equals Ms. Van Cleve, then Ms. Van Cleve did it in the gallery with the trophy! should be printed to the console.
*/
/*
* Programming Quiz: Murder Mystery (3-4)
*/
// change the value of `room` and `suspect` to test your code
var room = "gallery";
var suspect = "Ms. Van Cleve";
var weapon = "";
var solved = false;
if (room === "ballroom" && suspect === "Mr. Kalehoff") {
weapon = "poison";
solved = true;
} else if (room === "gallery" && suspect === "Ms. Van Cleve") {
weapon = "trophy";
solved = true;
} else if (room === "billiards room" && suspect === "Mrs. Sparr") {
weapon = "pool stick";
solved = true;
} else {
weapon = "knife";
solved = true;
}
if (solved) {
console.log(suspect + " did it in the " + room + " with the " + weapon + "!");
}