Math.random( ) returns a Number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
This function takes no arguments.
function tossCoin( ) {
var coin = Math.random( );
if ( coin < 0.5 ) return 2; else return 3; }
OK, coinToss—
we need to manipulate math.random( )—technically speaking, we need to give it an 'argument'.
But math.random( ) brooks no argument, so we'll give it an alias—'var' (for 'variable')—and call the alias 'coin'.
Now:
if 'coin', when tossed, is less than 0.5, give us a 2;
if it's equal to or more than 0.5, make it a 3.
Easy.
https://archive.org/details/msdos_I_CHING_shareware
https://archive.org/details/Big_Red_398_I_Ching
https://archive.org/details/603_Anthology_Poole_Pilot_-I_Ching_Diskcat
top