JS Built-ins
cryptointermediate

crypto β€” UUID matches format

πŸ“– Usage Example
const uuid = crypto.randomUUID()
/^[0-9a-f-]{36}$/.test(uuid)  // β†’ true

A UUID v4 matches the hexadecimal format with hyphens at fixed positions.

crypto.randomUUID() β€” format validation

A UUID has a specific format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is a hex digit and y is 8, 9, a, or b.

Challenge: Verify that a UUID matches the standard UUID v4 format.

πŸ’‘ Hints (1)
  • β€’ The third group always starts with 4 to indicate version 4