Preparing search index...
    • Shuffles an array using the Fisher-Yates algorithm and optionally returns a subset

      This function creates a shuffled copy of the input array without modifying the original. Optionally returns only the first N elements from the shuffled array.

      Type Parameters

      • T

      Parameters

      • arrayToShuffle: T[]

        The array to shuffle

      • OptionalnumberOfElementsWanted: number

        Optional number of elements to return from shuffled array

      Returns T[]

      Shuffled array or subset of shuffled array

      const recipes = [recipe1, recipe2, recipe3, recipe4, recipe5];
      const shuffled = fisherYatesShuffle(recipes, 3); // Returns 3 random recipes