No results for

Powered byAlgolia
⚠️ This is archived documentation for v0.33. Go to the latest version

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.1.0/index.js";
let names = ['John', 'Jane', 'Bert', 'Ed'];
export default function() {
let randomName = randomItem(names);
console.log(`Hello, my name is ${randomName}`)
}