随机获取1到100的10个数

xiaoxiao2021-02-28  71

function getRandom(start, end) { var num = end - start + 1; return Math.floor(Math.random() * num ); } var arr = []; for (var i = 0; i < 10; i++) { arr.push(getRandom(1, 100)); } arr.sort(function (a, b) { return (a - b); }); console.log(arr);
转载请注明原文地址: https://www.6miu.com/read-2621235.html

最新回复(0)