flip coin javascript code example
Example 1: flip a coin javascript
function coinFlip() {
return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
}
Example 2: flip a coin javascript
function coinFlip() {
return Math.floor(Math.random() * 2);
}