1.0.0 • Published 1 year ago

fisher-yates-shuffle-js v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Shuffle

This is implementation of the Fisher-Yates shuffle algorithm in JavaScript. It's puts all items of given array in random order.

Installation

npm install fisher-yates-shuffle-js

Usage

const shuffle = require ('fisher-yates-shuffle-js');

var exampleArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

var shuffledArray = shuffle (exampleArray);

console.log (shuffledArray)

Example output:

[
  5, 7, 10, 9, 4,
  3, 2,  1, 6, 8
]