dice roller javascript

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

// Examples
throwdice();  //2
Source

Also in JavaScript: