cowboy name generator

 

 

🤠 Cowboy Name Generator 🤠

Saddle up and find your Wild West name!

“Wild Bill Hickok”


Your Cowboy Names

let currentType = 'gunslinger'; let history = [];

function getRandomElement(array) { return array[Math.floor(Math.random() * array.length)]; }

function generateCowboyName() { const style = cowboyParts[currentType];

// Generate name parts const prefix = getRandomElement(style.prefixes); const middle = getRandomElement(style.middles); const suffix = getRandomElement(style.suffixes);

// Combine name let name = `${prefix} ${middle} ${suffix}`;

// Display the name document.getElementById("cowboyDisplay").textContent = `"${name}"`;

// Add to history history.unshift(name); updateHistory(); }

function setType(type) { currentType = type;

// Update active button styling document.querySelectorAll('.type-btn').forEach(btn => { btn.classList.remove('active'); }); event.target.classList.add('active');

// Generate a new name with this type generateCowboyName(); }

function updateHistory() { const historyContainer = document.getElementById("historyCowboys"); historyContainer.innerHTML = "";

// Display last 10 names const recentHistory = history.slice(0, 10); recentHistory.forEach(name => { const cowboyElement = document.createElement("div"); cowboyElement.className = "history-cowboy"; cowboyElement.textContent = `"${name}"`; historyContainer.appendChild(cowboyElement); }); }

// Generate first name on load window.onload = generateCowboyName;