0.0.2 • Published 2 years ago

random-array-item v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Random Array Item

Build Downloads this Week Bundle Size Version

Numify

:unicorn: Simple utility to fetch a random item from an array.

:package: Requirements

Node.js 12.x LTS or 14.x (or Higher) LTS

:sparkles: Installation

Install the NPM Package with the below command:

npm install random-array-item --save

(or)

Install with Yarn:

yarn add random-array-item

:pen: Usage

Import the module in your project:

// Commonjs Import
var { randomArrayItem } = require("random-array-item");

// or ES6 import
import { randomArrayItem } from "random-array-item";

:bulb: Example

Pass the Array to the function

import { randomArrayItem } from "random-array-item";

let array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
let randomItem = randomArrayItem(array);
console.log(randomItem);

:ballot_box_with_check: Example Output

7

:shield: LICENSE

  • MIT

:green_heart: Message

I hope you find this useful. If you have any questions, please create an issue.


💰 Help me with your donation