Skip to main content

Function: generateId()

generateId(prefix, n): string

Generates a unique ID string, typically used as a DOM element ID.

Parameters​

• prefix: string = 'racingbars'

String prefix for the ID (default: 'racingbars').

• n: number = 8

Number of random characters to append (default: 8).

Returns​

string

A unique ID string combining the prefix and random characters.

Example​

generateId();                  // 'racingbars_a1b2c3d4'
generateId('chart', 6); // 'chart_x1y2z3'

Defined in​

lib/utils/utils.ts:99