probability in javascript help?

后端 未结 6 1850
-上瘾入骨i
-上瘾入骨i 2020-12-28 10:06

Sorry, I\'m new to JS and can\'t seem to figure this out: how would I do probability?

I have absolutely no idea, but I\'d like to do something: out of 100% chance, m

6条回答
  •  长发绾君心
    2020-12-28 10:30

    var decide = function(){ 
        var num = parseInt(Math.random() * 10) + 1; // assigns num randomly (1-10)
        num > 7 ? d() : e(); // if num > 7 call d(), else call e() 
    };
    

提交回复
热议问题