-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
43 lines (40 loc) · 1.43 KB
/
index.html
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
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>HTML + CSS</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="gameContainer">
<p>
<img src="image.png" alt="Image" height="200" width="450"/>
<h1>Random Number Game!</h1>
<h2>fun!</h2>
<p>Guess a Number from 1 to 100!</p>
<input type = "number" id = "guessInput" place holder = "Put a Number
here" min = "1" max = "100">
<button onclick="checkUserGuess()">Check</button>
<p id="message"></p>
<h3>haha!</h>
</div>
<script> //Java
let randomNumber = Math.floor(Math.random() * 100) + 1;
function checkUserGuess() {
const userGuess = document.getElementById("guessInput").value;
const message = document.getElementById("message");
if (userGuess == randomNumber) {
message.textContent = `You are Correct!`;
} else if (userGuess < randomNumber) {
message.textContent = "Higher. Try Again.";
} else if (userGuess > randomNumber) {
message.textContent = "Lower. Try Again.";
} else {
message.textContent = "Put a number!!";
}
}
</script>
</body>
</html>