Random Name Generator
Click the button to generate a random name:
<p>Click the button to generate a random name:</p>
<p id="randomName"> </p>
<p><button onclick="generateRandomName()">Submit</button></p>
<script>
function generateRandomName() {
// Define lists of names
var firstNames = ['Alice', 'Bob', 'Charlie', 'David', 'Eve'];
var lastNames = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown'];
var nicknames = ['Sunny', 'Buddy', 'Sparky', 'Lucky', 'Daisy'];
// Randomly select names from each list
var firstName = firstNames[Math.floor(Math.random() * firstNames.length)];
var lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
var nickname = nicknames[Math.floor(Math.random() * nicknames.length)];
// Concatenate the names
var fullName = firstName + ' ' + lastName + ' ' + nickname + '';
// Display the random name
document.getElementById("randomName").textContent = fullName;
}
</script>