练习点菜及用的公式

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<!--点菜-->
<body>
<script type="text/javascript">
var cai = ['水煮肉片','鱼香肉丝','红烧肉','干煸豆角','可乐鸡翅','水煮鱼'];
//var 变量名 = Math.floor(Math.random()*(Y+1-x)+x) 公式
//6 = cai.length - 1 6 = cai.length-1 +1 -1 +1
var dian = Math.floor(Math.random()*(6+1-0)+0);
document.write(cai[dian]);
</script>
</body>
</html>

posted @ 2020-04-03 12:27  妹妹早上好  阅读(282)  评论(0编辑  收藏  举报