Shuffle and shorten an array.
// randomArray(originArray)
randomArray([1, 2, 3, 4, 5, 6]);
// [4, 5, 3, 2, 1]
// randomArray(originArray, maxLength)
randomArray([1, 2, 3, 4, 5, 6], 2);
// [5, 3]
// randomArray(originArray, [minLength, maxLength])
randomArray([1, 2, 3, 4, 5, 6], [3, 5]);
// [4, 6, 2, 3]
<script src="https://unpkg.com/@libshin/random-array(@version)/build/random-array.umd.js"></script>
You don't have to specify the version of the module. By default it will redirect to the latest version.
npm i --save @libshin/random-array
yarn add @libshin/random-array
const randomArray = window["@libshin/random-array"];
const randomArray = require("@libshin/random-array");
import randomArray from "@libshin/random-array";