Trường · Weighted Array Element

Trường · Weighted Array Element · helpers.weightedArrayElement. Phương thức tạo · Ví dụ

helpers.weightedArrayElement

Cài đặt trình tạo

Tạo dữ liệu để xem kết quả ở đây.

Tham số & Ví dụ

Returns a weighted random element from the given array. Each element of the array should be an object with two keys weight and value.

helpers.weightedArrayElement(array: ReadonlyArray<{ weight: number; value: T; }>)
array
Array to pick the value from.
array[].weight
The weight of the value.
array[].value
The value to pick.

Ví dụ

"draft"

Dùng dữ liệu tổng hợp trong môi trường kiểm thử.

Trình tạo liên quan

Khám phá kịch bản