Calculate the total of math.random in javascript and return a value

I have three variables that store the random number generated by math.random (), then I have three other variables that store the addition of these three variables, like this:
 var zikT = 0; var hamT = 0; var musT = 0; $("#reset").click(function(){ var random = Math.floor(Math.random() * 12 + 1); var random_0 = Math.floor(Math.random() * 12 + 1); var random_1 = Math.floor(Math.random() * 12 + 1); zikT += (random_0); hamT += (random); musT += (random_1); }) 


My dilemma is that in p the p tag with id leader I want the name of the person who has the largest number that i know i can not explain but i want to do something below:
 if(zikT > hamT && zikT > musT){ $("#leading").html('you'); }else if(hamT > zikT && hamT > musT){ $("#leading").html('me'); } else if(musT > zikT && musT > hamT){ $("#leading").html('i'); } 

Read More Articles

0 Comments:

Posting Komentar