MCPcopy Create free account
hub / github.com/dailydotdev/apps / getRandom4Digits

Function getRandom4Digits

packages/shared/src/lib/numberFormat.ts:29–37  ·  view source on GitHub ↗
(leftPad?: string)

Source from the content-addressed store, hash-verified

27}
28
29export const getRandom4Digits = (leftPad?: string): string => {
30 const random = Math.floor(1000 + Math.random() * 9000);
31
32 if (!leftPad) {
33 return random.toString();
34 }
35
36 return random.toString().padStart(4, leftPad);
37};
38
39export const removeNonNumber = (value: string): string =>
40 value.replace(/,(\d{2})$/, '.$1').replace(/[^\d.]/g, '');

Callers 1

useSquadCreateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected