JavaScript version
throwdice.js
const throwdice = () => ~~(Math.random() * 6) + 1;
TypeScript version
throwdice.ts
const throwdice = (): number => ~~(Math.random() * 6) + 1;
Examples
examples.js
throwdice(); // 4
throwdice(); // 1
throwdice(); // 6