我看不出我做错了什么
var user = prompt ("You are minding you own bissueness when a man in a big white van pulls up? What do you do run, pop a cap in his *error 343*, or hop in?").toLowerCase();
switch (user)
case 'run':
var headstart = propmt ("Let's hit it. Did you run track or Cross Country this year? Yes or no?").toLowerCase();
var fast = prompt ("Are you fast? Yes or No?").toLowerCase();
if (headstart === 'yes' || fast === 'yes')
{
console.log("You live to cruze another day?");
}
else
{
console.log("Sorry... you were taken and sold in to Mexico");
}
break;
case 'pop a cap in his *error 343*':
var gun = prompt(" Ok, we went with gun. Do you have a gun on you? Yes or No").toLowerCase()
var loaded = prompt("Is you gun loaded? Yes or No?").toLowerCase()
if (gun === 'yes' && loaded === 'yes')
{
console.log("There were no witnesses, you get away clean!");
}
break;
case 'hop in':
console.log("He turned out to be a nice man and lets you work in Mexico for free forever!")
break;
default:
console.log("I didn't understand your choice.");
}
答案 0 :(得分:-1)
切换后的所有东西都需要在波浪形支架内。我今天早些时候遇到了同样的问题。
你有:
switch(x)
case 1:
//statement
break;
case 2:
//statement
break;
你应该拥有什么:
switch(x)
{ //You were missing this bracket
case 1:
//statement
break;
case 2:
//statement
break;
} //You were also missing this bracket