Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get random item in array

function getRandomNumberElement(items: number[]): number {
    let randomIndex = Math.floor(Math.random() * items.length);
    return items[randomIndex];
}
Code language: TypeScript (typescript)
Source by www.typescripttutorial.net #
 
PREVIOUS NEXT
Tagged: #random #item #array
ADD COMMENT
Topic
Name
2+5 =