POST 27: RANDOMADDNESS

Today I made a random number generator

const myButton = document.getElementById("myButton");
const label1 = document.getElementById("label1");
const label2 = document.getElementById("label2");
const label3 = document.getElementById("label3");

These are the buttons

const min = 1;
const max = 6;
let randomNum1;
let randomNum2;
let randomNum3;

this controls the max and min of the numbers given

myButton.onclick = function(){
    randomNum1 = Math.floor(Math.random() * max) + min;
    randomNum2 = Math.floor(Math.random() * max) + min;
    randomNum3 = Math.floor(Math.random() * max) + min;
    label1.textContent = randomNum1;
    label2.textContent = randomNum2;
    label3.textContent = randomNum3;
}

these allow the buttons to work

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top