No results for

Powered byAlgolia

randomItem(array)

suggest edits

Function returns a random item from an array.

ParameterTypeDescription
arrayOfItemsarrayArray [] of items

Returns

TypeDescription
anyRandom item from the array

Example

import { randomItem } from "https://jslib.k6.io/k6-utils/1.0.0/index.js";
let names = ['John', 'Jane', 'Bert', 'Ed'];
export default function() {
let randomName = randomItem(names);
console.log(`Hello, my name is ${randomName}`)
}