Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
17
function
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
generateRandomExam
Function · 0.85
Calls
no outgoing calls
Tested by
no test coverage detected