This module contains routines for objects manipulation
- Source:
Methods
(static) getRandomValue(pattern, list) → {*}
This is a function to retrieve a random value from a list of key-value
pairs, where the keys satisfy a given regular expression
Parameters:
Name | Type | Description |
---|---|---|
pattern |
string | A regular expression |
list |
object | A list of key-value pairs |
- Source:
Returns:
random value
- Type
- *
Example
let
strings = {
HELLO_1: 'Привет!',
HELLO_2: 'Hi',
HELLO_3: 'Салам!',
HELLO_4: 'Guten Tag!',
HELLO_5: 'Hola!'
},
pattern = 'HELLO_\\d',
result;
result = getRandomValue(pattern, strings);
console.log(result); // value of random strings list's item (for example - 'Hi')