How to make a button Randomly?

Help to make random button pressing which with the chance of 35% run a function!...

Function:
uCodesRep function(id) {
 var uRate = $('.uV' + id).text();
 var uRall = Number(uRate) + Number(1);
 var uHost = location.href;
 $('.uV' + id).html(uRall);
 $('.uR' + id).hide();
 var uSid = $('.uId' + id).attr("href").split('-')[1];
 var uSms = $('.message_place' + id).html();
 $.get('/index/23-' + uSid, function(data) {
 $.post('/index/', {
 act: 2,
 a: 23,
 t: 1,
 reason: 'Test' + uSms + ",
 s: uSid
 ref: uHost,
 sos: $('input[name="sos"]').val(),
 ssid: ssid = $('input[name="ssid"]').val()
 }, function() {});
});
};
July 9th 19 at 13:31
1 answer
July 9th 19 at 13:33
withChance function(chance) {
 const randInt = Math.the round(Math.random() * 100)
 return randInt + chance >= 100 ? true : false
}

document.querySelector('button').onclick = () => {
 if (withChance(35)) {
alert('OK')
}
}
simple and beautiful - Henderson_Beat commented on July 9th 19 at 13:36
: thanks =) - aiyana.Marv commented on July 9th 19 at 13:39
: or even
const withChance = chance => Math.floor(chance / 100 + Math.random())
- aiyana.Marv commented on July 9th 19 at 13:42
: huh?)) Explain something finally understood nothing. - aiyana.Marv commented on July 9th 19 at 13:45
: utter crap. Okay, there is no point in talking about it, good luck. - aiyana.Marv commented on July 9th 19 at 13:48

Find more questions by tags JavaScript