<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Object</title>
</head>
<body>
<script>
// 取任意值之间 eg:0-10之间
console.log("取10以内的随机数"+Math.random()*10);
// 数字取最大整数
var b = Math.floor(Math.random()*10);
console.log("取整数为:" + b);
var c = Math.floor(Math.random * (20-2) + 2);
var d = Math.floor(Math.random * (46 - 11) + 11);
console.log("2 到 20 之 间 的 随 机 数:" + c);
console.log("11 到 46 之 间 的 随 机 数 :" + d);
</script>
</body>
</html>
2 到 20 之 间 的 随 机 数:NaN
Math.html:26 11 到 46 之 间 的 随 机 数 :NaN
少了一个括号
var c = Math.floor(Math.random() * (20-2) + 2);
// 取任意值之间 eg:0-10之间
console.log("取10以内的随机数"+Math.random()*10);
// 数字取最大整数
var b = Math.floor(Math.random()*10);
console.log("取整数为:" + b);
var c = Math.floor(Math.random() * (20-2) + 2); //Math.random之后少了()括号
var d = Math.floor(Math.random() * (46 - 11) + 11); //Math.random之后少了()括号
console.log("2 到 20 之 间 的 随 机 数:" + c);
console.log("11 到 46 之 间 的 随 机 数 :" + d);