如何写啊 可以告诉我嘛?很想知道,感觉好难,,太南了
告诉我怎么做
看看可行?
<!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>Document</title>
</head>
<body>
<script>
const input = parseInt(prompt("输入一个整数"));
if (!input || input < 1) {
console.log("请输入一个大于0的整数");
} else {
const n = 10 ** (input - 1);
let result = Math.random();
while (result < n) {
result *= 10;
}
result = parseInt(result);
console.log(result);
}
</script>
</body>
</html>
你说的啥意思,是要生成一个随机数,然后和用户输入的做比对吗?