MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / getRandomElement

Function getRandomElement

api/src/utils/exam.ts:17–20  ·  view source on GitHub ↗
(arr: T[])

Source from the content-addressed store, hash-verified

15}
16
17function getRandomElement<T>(arr: T[]): T {
18 const id: number = Math.floor(Math.random() * arr.length);
19 return arr[id] as T;
20}
21
22/**
23 * Generates a random exam.

Callers 1

generateRandomExamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected