Emulate a dice throw
JavaScript
const throwdice = () => ~~(Math.random() * 6) + 1
TypeScript
const throwdice = (): number => ~~(Math.random() * 6) + 1
Examples
throwdice() // 4
throwdice() // 1
throwdice() // 6
const throwdice = () => ~~(Math.random() * 6) + 1
const throwdice = (): number => ~~(Math.random() * 6) + 1
throwdice() // 4
throwdice() // 1
throwdice() // 6