pucchinglgl/src/randomInt.ts

8 lines
200 B
TypeScript

const { floor, random } = Math;
/** 範囲 [0, high] のランダムな整数を返します */
function randomInt(high: number) {
return floor(random() * (high + 1));
}
export default randomInt;