|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
543 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Returns a random element from an array.
|
|---|
| 3 | *
|
|---|
| 4 | * This function takes an array and returns a single element selected randomly from the array.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T - The type of elements in the array.
|
|---|
| 7 | * @param {T[]} arr - The array to sample from.
|
|---|
| 8 | * @returns {T} A random element from the array.
|
|---|
| 9 | *
|
|---|
| 10 | * @example
|
|---|
| 11 | * const array = [1, 2, 3, 4, 5];
|
|---|
| 12 | * const randomElement = sample(array);
|
|---|
| 13 | * // randomElement will be one of the elements from the array, selected randomly.
|
|---|
| 14 | */
|
|---|
| 15 | declare function sample<T>(arr: readonly T[]): T;
|
|---|
| 16 |
|
|---|
| 17 | export { sample };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.