-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.html
More file actions
42 lines (37 loc) · 1.1 KB
/
random.html
File metadata and controls
42 lines (37 loc) · 1.1 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
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>random number</title>
</head>
<body>
<div>
<h1>random</h1>
<button onclick="random()">click to guess</button>
</div>
<script>
var min = 1;
var max = 100;
function random(){
attempt = 6 ;
let randomNo = Math.floor(Math.random()*(max - min + 1)) + min;
console.log(randomNo);
while(attempt > 0){
let guessNo = parseInt(prompt("enter the guess no."))
if(randomNo == guessNo){
alert("you guess the right no.");
}
else if (randomNo > guessNo){
alert("your guess is to low");
}
else if (randomNo < guessNo ){
alert("your guess is too high");
}
attempt --;
}
alert("your attempt is out");
}
</script>
</body>
</html>