JavaScript Dice Roll When Button Is Clicked
<p>I am trying to make a simple dice roller with Javascript that will display a random number between 1 and 6 when the button is clicked.</p>

<p>I have a button:</p>

<pre><code>&lt;button id="roll"&gt;Click to Roll&lt;/button&gt;
</code></pre>

<p>With this script:</p>

<pre><code>function diceRoll(min, max) {
    var min = Math.ceil(min);
    var max = Math.floor(max);
    var roll = Math.floor(Math.random() * (max - min + 1)) + min;
    console.log(roll);
}

document.getElementById("roll").onclick = diceRoll(1, 6);
</code></pre>

<p>The random number will display when the page is first loaded, but when clicking the button nothing happens. How can I get this to work when the button is clicked, not when the page is loaded? Thank you.</p>