How do I make it so ..
sendMessage(\"hi\");
sendMessage(\"bye\");
Yes, Math.random()
is an excellent way to accomplish this. What you want to do is compute a single random number, and then make decisions based on that:
var d = Math.random();
if (d < 0.5)
// 50% chance of being here
else if (d < 0.7)
// 20% chance of being here
else
// 30% chance of being here
That way you don't miss any possibilities.