how do i implement probability in java script

i was wonder how i would use probability in script for unity preferably java. some examples like: the probability the Ai soldir in the game will see your player when he's wearing camo. like how would i use it so there is a 60 percent chance the Ai will spot you when a bool prop is true or say a card game like poker and getting random cards. any type of explination will be appreciated preferably a example for each typed in script

You would want to generate a random number, using `Random.Range(min, max)` - (`min` is inclusive, `max` is exclusive). Read more here.

A simple example for the soldier situation could be:

 var soldierCanSeeYou : bool = true;

 // if prop is true and a random number between 0 and 100 is less than 60 (60% chance)
 if (soldierCanSeeYou && Random.Range(0, 100) <= 60) {
      // Soldier has spotted you (run!!!)

another for the cards example:

 function getRandomCard() {
      var cards = new Array( '1', '2', '3', '4', '5', '6', '7', '8', '9', 'J', 'Q', 'K', 'A' ); // an array containing all the possible types of cards to get
      return cards[Random.range(0, cards.length)]; // use the Random.Range() function again to get a random card in the array and return it