logo
logo

Get Random Element

Get Random Element

Create a function called
getRandomElement
that takes in an array and returns a random element from the array. If the array is empty, throw a range error with the message 'Array is empty'.
Console
Submit
Solution
00:00