The prefix string for the phone number (default: "010")
A formatted mobile phone number string
RandomGenerator.mobile(); // e.g. "0103341234" or "01012345678"
RandomGenerator.mobile("011"); // e.g. "0119876543" or "01112345678"
RandomGenerator.mobile("+82"); // e.g. "+823341234" or "+8212345678"
// Generate test user phone numbers
const testUsers = Array.from({ length: 100 }, () => ({
name: RandomGenerator.name(),
phone: RandomGenerator.mobile(),
altPhone: RandomGenerator.mobile("011"),
}));
// Create international phone numbers
const internationalPhone = RandomGenerator.mobile("+821");
// Generate contact list for testing
const contacts = ["010", "011", "016", "017", "018", "019"].map(
(prefix) => ({
carrier: prefix,
number: RandomGenerator.mobile(prefix),
}),
);
contracts/common.md#principled-implementation A mobile number is the prefix, a middle group of three digits when the drawn value is below 1,000 and four digits otherwise, and a four-digit group, all zero-padded, which matches the 010-XXX-XXXX and 010-XXXX-XXXX Korean formats the default prefix implies.
Generates a random mobile phone number with customizable prefix.
Creates a mobile phone number in the format: [prefix][3-4 digits][4 digits]. The middle section is 3 digits if the random number is less than 1000, otherwise 4 digits. The last section is always 4 digits, zero-padded if necessary. Commonly used for generating Korean mobile phone numbers or similar formats.
Processing cost: Two bounded integer draws and fixed-width decimal formatting use constant work; joining the caller prefix costs O(P) output time and space for P prefix characters.