shuffleArray

A simple utility function that shuffles an array randomly. The shuffleArray function works generically and can shuffle arrays of any type.
> shuffleArray<T>(array: T[]): T[]
Parameters
  • array: An array of any type `T` that you want to shuffle.
  • Returns: A new array containing the elements of the input array, but in random order.

Example

import { shuffleArray } from "@explita/daily-toolset";

const array = [1, 2, 3, "a", "b", "c"];
const shuffledArray = shuffleArray(array);

console.log(shuffledArray); 
// Output: A randomly ordered array, e.g., ["c", 2, "b", 1, 3, "a"]