if statement - How can I repeat the Math.random process until the number is below 0.5? JavaScript -


var randomnum = math.random();  if(randomnum<0.5){     console.log("it me.");     console.log(randomnum); }  else if(randomnum>=0.5){     **//what do here repeat math.random process until number below 0.5?** } 

i new using javascript , can't seem figure out how this. want work when number above 0.5 picked, repeats math.random process without doing else until number below 0.5 picked. in end display "it me.", , number picked. possible? if so, can tell me how it?

i'm not sure why want this, while loop seems best fit:

var randomnum = math.random(); while(randomnum >= 0.5){    randomnum = math.random() } console.log("it me."); console.log(randomnum); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -