vendredi 22 mai 2020

Adding generated random numbers?

What I except from my code is to generate a random number and then it would generate another random number and then add it to the old generated random number and so on. Simply, every time I click on the button it will generate a random number and add it to the old generated random number.

function play() {
    let p1 = document.getElementById("demo1");
    let p2 = document.getElementById("demo2");

    rnd = Math.floor(Math.random() * 10);
    for (i = 0; i <= rnd; i++) {
    var d = rnd + rnd;
    p1.innerHTML = d;
                               }
}

This is the farthest point I've reached, and it only doubles the random generated number, so it is not useful at all for my goal. I appreciate the help.




Aucun commentaire:

Enregistrer un commentaire