https://github.com/mcnaveen/random-array-item
Simple utility to fetch a random item from an array
https://github.com/mcnaveen/random-array-item
array node-module nodejs random random-array
Last synced: 21 days ago
JSON representation
Simple utility to fetch a random item from an array
- Host: GitHub
- URL: https://github.com/mcnaveen/random-array-item
- Owner: mcnaveen
- License: mit
- Created: 2022-03-06T09:06:27.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-06T09:09:58.000Z (over 4 years ago)
- Last Synced: 2024-12-29T18:52:48.310Z (over 1 year ago)
- Topics: array, node-module, nodejs, random, random-array
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/random-array-item
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Random Array Item





: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:
```javascript
// 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
```javascript
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
