GitHub 6521★

Emulate a dice throw

JavaScript version

const throwdice = () => ~~(Math.random() * 6) + 1;

TypeScript version

const throwdice = (): number => ~~(Math.random() * 6) + 1;

Examples

throwdice(); // 4
throwdice(); // 1
throwdice(); // 6
Follow me on and to get more useful contents.