我无法完成这个 javascript 来转换咖啡价格..我下载了一个调试器,它一直告诉我价格未定义,我不明白..这是脚本..
<html>
<head>
<title>Coffee House</title>
</head>
<body>
<script type="text/javascript">
var drink, ounces, price;
prompt ( "Enter the drink type: espresso, latte, cappuccino, americano" );
prompt ( "Enter the oz: 8, 12, 16" )
var shots = prompt ( "Enter the number of shots" )
if ( drink == "espresso")
price = 1.40;
if (( drink == "latte") || (drink == "cappuccino" )) {
if ( ounce == 8 )
price = 1.95;
else if ( ounce == 12 )
price = 2.35;
else if ( ounce == 16 )
price = 2.75;
}
if ( drink == "americano" )
price = 1.20 + ( ( (ounce -8)/8 ) * .30 );
price = price + ( (shots) * .50 );
price = "price" * 1.055;
price = Math.round( price * 100 )/100;
alert( "Your " + ounce + "oz. " + drink + "with " + shots + "shots of espresso costs: $ " +price );
</script>
</body>
</html>