我错过了什么?
在这个谋杀之谜中有:
四个房间:舞厅、画廊、台球室和餐厅,四种武器:毒药、奖杯、台球杆和刀,四个嫌疑人:帕克斯先生、范克莱夫女士、斯帕尔女士和先生. 卡莱霍夫。我们也知道每个武器对应一个特定的房间,所以......
而且我们知道,在谋杀案发生时,每个嫌疑人都位于一个特定的房间。
为了帮助解开这个谜团,请编写以下条件语句的组合:
之后,如果谜题解决了,将以下内容打印到控制台:
__________ 是在 __________ 中与 __________ 一起完成的!
所以我输入了以下内容
// change the value of `room` and `suspect` to test your code
var room = "dining room";
var suspect = "Mr. Parkes";
var weapon = "knife";
var solved = false;
if (room == "gallery" && suspect == "Ms. Van Cleve") {
solved = true;
weapon == "trophy";
} else if (room == "dining room" && suspect == "Mr. Parkes") {
solved = true;
weapon == "knife";
} else if (room == "billiards room" && suspect == "Mrs. Sparr") {
solved = true;
weapon == "pool stick";
} else { room == "ballroom";
suspect == "Mr. Kalehoff";
weapon == "poison";
solved = true;
}
if (solved) {
console.log(suspect + "did it in the" + room + "with the" + weapon +"!");
}
但不断得到
再试一次
进展顺利
什么地方出了错
你没有完成解开谜团的两个步骤。
为了帮助解开这个谜团,请编写以下条件语句的组合:
1) 根据房间设置武器的值,如果房间的值与嫌疑人的房间匹配,则将解决的值设置为真
你应该有一个 if 语句
if (room == "dining room")
{
//set weapon
}
else if (room == "ballroom")
{
//set weapon
}
else if (room == "billiards room")
{
//set weapon
}
else if (room == "gallery")
{
//set weapon
}
此外,您的 else-if 中的条件语句不正确。应该是 || 不是 &&
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句