If you need a simple choice between one thing or another, here's a function that generates a random number between 0 and 1 and returns it.

```
function coinFlip() {
return Math.floor(Math.random() * 2);
}
```

If you prefer true or false values...

```
function coinFlip() {
return (Math.floor(Math.random() * 2) == 0);
}
```

Or if you really want to stick to the whole heads/tails thing..

```
function coinFlip() {
return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
}
```

=== 0