js生成随机数代码
2024-01-18可以使用以下代码生成随机数: javascript hljs复制代码// 生成0到1之间的随机数 var randomNum = Math.random(); // 生成指定范围内的随机整数 function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min 1)) min; } console.log(randomNum); console.log(getRa