I am looking to create a button that changes to true in the Script section. This will allow for a random number to be displayed in the paragraph element.
<!doctype html>
<html>
<button id="button">
random number
</button>
<p id="randomnumber">
</p>
</html>
<script>
var randomNumber;
document.getElementById('button').addEventListener('click', function() {
randomNumber = (Math.floor(Math.random()*21)+2);
document.getElementById("randomnumber").innerHTML = randomNumber;
});
</script>
Edit: I am also interested in learning how to assign the random number to a variable so I can utilize it elsewhere.