-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6.html
More file actions
38 lines (33 loc) · 1.09 KB
/
Copy path6.html
File metadata and controls
38 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Greeting Generator</title>
</head>
<body>
<h1>Random Greeting Generator</h1>
<p id="wish"></p>
<input type="text" id="name" placeholder="Enter your name">
<button id="generateButton">Generate Greeting</button>
<script>
const wishes = [
"Hey",
"Hello",
"Hi",
"Hola",
"Heya"
];
const wishElement = document.getElementById("wish");
const generateButton = document.getElementById("generateButton");
function generateRandomWish() {
const randomIndex = Math.floor(Math.random() * wishes.length);
const randomWish = wishes[randomIndex];
const name = document.getElementById("name").value || "Friend";
wishElement.textContent = `${randomWish}, ${name}!`;
}
generateButton.addEventListener("click", generateRandomWish);
generateRandomWish();
</script>
</body>
</html>