dimanche 30 décembre 2018

Logic of if statement only reaches 9/10

The code is supposed to award the majority of 10 flips to the winner coin side. However it is only going to 9 flips and rewarding the majority out of the 9.

I have tried tempering around the numbers, but none have succeeded. upon changing the percentage to 110 the total flips only goes to 7

if(51 <= heads_counter / wins * 100 && tails_counter / wins * 100 <= 49){
            placeholder.innerText = ("Heads Wins!");
            heads_counter = 0;
            tails_counter = 0;
        //if the majority of total flips is tails, "Tails wins!" is displayed
        }else if (51 <= tails_counter / wins * 100  && heads_counter / wins * 100 <= 49){
            placeholder.innerText = ("Tails Wins!");
            heads_counter = 0;
            tails_counter = 0;
        //if flips are tied, "Tie!" is displayed
        }else if(tails_counter / wins * 100 == 50 && heads_counter / wins * 100 == 50){
            placeholder.innerText = ("Tie!")
            heads_counter = 0;
            tails_counter = 0;
        }

the flip counter should only be going to best out of 10 then reset, but they are only going to 9

Aucun commentaire:

Enregistrer un commentaire