Random Hobby Picker using HTML, CSS, and javaScript
Attempting to create a random hobby picker to help me with my ADHD.
<!DOCTYPE html>
<html>
<head>
<title>Random Hobby Picker</title>
<style>
/* Add some basic styling to the page */
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
margin-top: 50px;
}
.container {
text-align: center;
margin-top: 50px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Random Hobby Picker</h1>
<div class="container">
<p>Your random hobby for the day is:</p>
<h2 id="hobby"></h2>
<button onclick="pickHobby()">Pick a Hobby</button>
</div>
<script>
// Define the list of hobbies
var hobbies = ['Miniature Painting', 'Book Reading', 'Guitar Playing',
'3D Printing', 'Video Gaming', 'Drums'];
function pickHobby() {
// Select a random hobby from the list
var randomIndex = Math.floor(Math.random() * hobbies.length);
var hobby = hobbies[randomIndex];
// Update the hobby text on the page
document.getElementById('hobby').innerHTML = hobby;
}
</script>
</body>
</html>