这里有新用户。 任何人都可以帮我解决这个问题吗? 请在此处提出问题http://i.imgur.com/e8UbQfB.jpg
这是我到目前为止所做的工作,当然是错误的,如果我使用switch case是正确的吗?或者也许我可以使用if ... else语句?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var price;
var weight = parseFloat(prompt("Enter amount of laundry: ", ""));
var rate;
switch (weight)
{
case 1:
rate = weight <= 10;
price = 2.00;
break;
case 2:
rate = weight >= 10 && weight <= 20;
price = 1.50;
break;
case 3:
rate = weight >= 20;
price = 1.00;
break;
}
var total = price * weight;
alert
(
"\nWeight : " + weight +
"\nRate : " + price +
"\nTotal : RM " + total
);
</script>
</head>
</html>`