dimanche 20 août 2017

how do i rank the first place

I really need help with this little problem im having to rank the first person according to the highest score .

     //variables where the total value will go for each person  
            var musT = 0;
            var zikT = 0;
            var hamT = 0;

     // if the spacebar is pressed
     document.body.onkeyup = function(e){
        if(e.keyCode == 32){

          //generate random integers between 1 and 12
            var person_0 = Math.floor(Math.random() * 12 + 1);      
            var person_1= Math.floor(Math.random() * 12 + 1);      
            var person_2 = Math.floor(Math.random() * 12 + 1);  

            // add total number of pushups
            musT += musa;
            zikT += zikria;
            hamT += hamza;

            //displaying the total pushups
            $("#musT .box").html(musT);
            $("#zikT .box").html(zikT);
            $("#hamT .box").html(hamT);

            }

I wanna rank the highest number in a better way

            //ranking the top person

            if(musT > zikT && hamT){
                $("#first").html("Musa: " + musT );
            } if(zikT > musT && hamT){
                $("#first").html("Zikria: " + zikT );

            } if(hamT > musT && zikT){
               $("#first").html("Hamza: " + hamT ); 

     }
 }

Aucun commentaire:

Enregistrer un commentaire