Last active
September 25, 2025 05:14
-
-
Save Bandit/49cd230e0f13081d22cdea01dcc03b6c to your computer and use it in GitHub Desktop.
Alliterative random username generator. Example: https://jsfiddle.net/morbandit/e0ta9bxy/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Generates a random username, preferring alliteration where possible | |
| * @returns {string} A randomly generated username (e.g. "Perfect Pelican") | |
| */ | |
| export const alliterativeUsername = () => { | |
| // Initial list from https://github.com/sindresorhus/superb/blob/main/superb-words.json | |
| const adjectives = [ | |
| "ace", "amazing", "astonishing", "astounding", "awe-inspiring", "awesome", "badass", "beautiful", "bedazzling", | |
| "best", "breathtaking", "brilliant", "charming", "classy", "cool", "dandy", "dazzling", "delightful", "divine", | |
| "epic", "excellent", "exceptional", "exquisite", "extraordinary", "fabulous", "fantastic", "fantabulous", "fine", | |
| "finest", "first-class", "first-rate", "flawless", "funkadelic", "geometric", "glorious", "gnarly", "good", | |
| "grand", "great", "groovy", "groundbreaking", "happy", "heavenly", "hunky-dory", "impeccable", "impressive", | |
| "incredible", "jaunty", "jovial", "jubilant", "keen", "kickass", "kryptonian", "laudable", "legendary", | |
| "lovely", "luminous", "magnificent", "majestic", "marvelous", "mathematical", "mind-blowing", "neat", "nice", | |
| "noble", "optimal", "original", "outstanding", "peachy", "perfect", "phenomenal", "pioneering", "polished", | |
| "posh", "praiseworthy", "premium", "priceless", "prime", "primo", "quality", "quick", "quirky", "rad", | |
| "remarkable", "riveting", "scrumtrulescent", "sensational", "shining", "slick", "smashing", "solid", | |
| "spectacular", "splendid", "splendiferous", "stellar", "striking", "stunning", "stupendous", "stylish", | |
| "sublime", "super", "super-duper", "super-excellent", "superb", "superior", "supreme", "sweet", "swell", | |
| "terrific", "tiptop", "top-notch", "transcendent", "tremendous", "unbeatable", "ultimate", "unreal", | |
| "valiant", "vibrant", "victorious", "well-made", "wicked", "wonderful", "wondrous", "world-class", "xenial", | |
| "x-factor", "yare", "youthful", "yummy", "zany", "zealous", "zesty" | |
| ]; | |
| const animals = [ | |
| "Aardvark", "Albatross", "Alligator", "Alpaca", "Ant", "Anteater", "Antelope", "Ape", "Armadillo", "Donkey", | |
| "Baboon", "Badger", "Barracuda", "Bat", "Bear", "Beaver", "Bee", "Bison", "Boar", "Buffalo", "Butterfly", | |
| "Camel", "Capybara", "Caribou", "Cassowary", "Cat", "Caterpillar", "Cattle", "Chamois", "Cheetah", "Chicken", | |
| "Chimpanzee", "Chinchilla", "Chough", "Clam", "Cobra", "Cockroach", "Cod", "Cormorant", "Coyote", "Crab", | |
| "Crane", "Crocodile", "Crow", "Curlew", "Deer", "Dinosaur", "Dog", "Dogfish", "Dolphin", "Dotterel", "Dove", | |
| "Dragonfly", "Duck", "Dugong", "Dunlin", "Eagle", "Echidna", "Eel", "Eland", "Elephant", "Elk", "Emu", | |
| "Falcon", "Ferret", "Finch", "Fish", "Flamingo", "Fly", "Fox", "Frog", "Gaur", "Gazelle", "Gerbil", "Giraffe", | |
| "Gnat", "Gnu", "Goat", "Goldfinch", "Goldfish", "Goose", "Gorilla", "Goshawk", "Grasshopper", "Grouse", | |
| "Guanaco", "Gull", "Hamster", "Hare", "Hawk", "Hedgehog", "Heron", "Herring", "Hippopotamus", "Hornet", "Horse", | |
| "Human", "Hummingbird", "Hyena", "Ibex", "Ibis", "Jackal", "Jaguar", "Jay", "Jellyfish", "Kangaroo", | |
| "Kingfisher", "Koala", "Kookabura", "Kouprey", "Kudu", "Lapwing", "Lark", "Lemur", "Leopard", "Lion", "Llama", | |
| "Lobster", "Locust", "Loris", "Louse", "Lyrebird", "Magpie", "Mallard", "Manatee", "Mandrill", "Mantis", | |
| "Marten", "Meerkat", "Mink", "Mole", "Mongoose", "Monkey", "Moose", "Mosquito", "Mouse", "Mule", "Narwhal", | |
| "Newt", "Nightingale", "Octopus", "Okapi", "Opossum", "Oryx", "Ostrich", "Otter", "Owl", "Oyster", "Panther", | |
| "Parrot", "Partridge", "Peafowl", "Pelican", "Penguin", "Pheasant", "Pig", "Pigeon", "Pony", "Porcupine", | |
| "Porpoise", "Quail", "Quelea", "Quetzal", "Rabbit", "Raccoon", "Rail", "Ram", "Rat", "Raven", "Red deer", | |
| "Red panda", "Reindeer", "Rhinoceros", "Rook", "Salamander", "Salmon", "Sand Dollar", "Sandpiper", "Sardine", | |
| "Scorpion", "Seahorse", "Seal", "Shark", "Sheep", "Shrew", "Skunk", "Snail", "Snake", "Sparrow", "Spider", | |
| "Spoonbill", "Squid", "Squirrel", "Starling", "Stingray", "Stinkbug", "Stork", "Swallow", "Swan", "Tapir", | |
| "Tarsier", "Termite", "Tiger", "Toad", "Trout", "Turkey", "Turtle", "Viper", "Vulture", "Wallaby", "Walrus", | |
| "Wasp", "Weasel", "Whale", "Wildcat", "Wolf", "Wolverine", "Wombat", "Woodcock", "Woodpecker", "Worm", "Wren", | |
| "Yak", "Zebra" | |
| ]; | |
| // 1. Pick a random animal | |
| const randomAnimal = animals[Math.floor(Math.random() * animals.length)]; | |
| const firstLetter = randomAnimal.charAt(0).toLowerCase(); | |
| // 2. Find all adjectives that start with the same letter | |
| const matchingAdjectives = adjectives.filter(adj => adj.charAt(0).toLowerCase() === firstLetter); | |
| // 3. If we found matching adjectives, pick one | |
| let randomAdjective; | |
| if (matchingAdjectives.length > 0) { | |
| randomAdjective = matchingAdjectives[Math.floor(Math.random() * matchingAdjectives.length)]; | |
| } | |
| // 4. Fallback: If no alliterative match was found, return a completely random pair | |
| else { | |
| randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)]; | |
| } | |
| // 5. Return in title case | |
| return `${randomAdjective} ${randomAnimal}`.toLowerCase().replace(/\b\w/g, s => s.toUpperCase()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment