Skip to content

dilums/coin-toss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoinToss

npm version 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:

npm install @dilums/cointoss

Usage

To use CoinToss in your JavaScript project, import the module and call the coinToss function:

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:

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.

About

Just a dummy repo to test NPM publishing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published