https://github.com/dilums/coin-toss
Just a dummy repo to test NPM publishing
https://github.com/dilums/coin-toss
Last synced: 4 months ago
JSON representation
Just a dummy repo to test NPM publishing
- Host: GitHub
- URL: https://github.com/dilums/coin-toss
- Owner: dilums
- License: mit
- Created: 2023-06-10T07:27:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-10T08:29:11.000Z (about 3 years ago)
- Last Synced: 2025-09-13T14:11:03.643Z (11 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CoinToss
[](https://www.npmjs.com/package/@dilums/coin-toss)
[](https://github.com/dilums/coin-toss/blob/main/LICENSE)
CoinToss is a lightweight JavaScript library that allows you to simulate a coin toss. With just a single function, you can quickly generate a random outcome of either "heads" or "tails."
## Installation
You can install CoinToss via npm:
```bash
npm install @dilums/cointoss
```
## Usage
To use CoinToss in your JavaScript project, import the module and call the `coinToss` function:
```javascript
const coinToss = require("@dilums/coin-toss");
const result = coinToss();
console.log(result ? 'Heads' : 'Tails');
```
The `coinToss` function returns a boolean value. When `true`, it represents "heads," and when `false`, it represents "tails."
## Examples
Here's a simple example of using CoinToss in a Node.js script:
```javascript
const coinToss = require("@dilums/coin-toss");
for (let i = 0; i < 5; i++) {
const result = coinToss();
console.log(`Toss ${i + 1}: ${result ? 'Heads' : 'Tails'}`);
}
```
Output:
```
Toss 1: Heads
Toss 2: Tails
Toss 3: Tails
Toss 4: Heads
Toss 5: Heads
```
## License
This project is licensed under the [MIT License](LICENSE).