Package Exports
- @chriscodesthings/randomize-array
- @chriscodesthings/randomize-array/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@chriscodesthings/randomize-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
randomize-array

Function to randomize an array
Description
Returns a copy of the array in a randomized order.
See...
Install
npm install --save @chriscodesthings/randomize-arrayUsage
import randomizeArray from '@chriscodesthings/randomize-array';
console.log(randomizeArray([1, 2, 3, 4, 5]));
// => [3, 2, 5, 1, 4]Syntax
randomizeArray(arr);Parameters
- arr: an array of things to randomize
Return Value
Returns a copy of arr in a random order.
Examples
// pick 2 security questions
function pickQuestions() {
const questions = [
"Favourite colour",
"Favourite food",
"Favourite place",
"Favourite TV show",
"Favourite song",
];
return randomizeArray(questions).splice(-2);
}