-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjogo_adivinha.html
More file actions
98 lines (89 loc) · 2.03 KB
/
Copy pathjogo_adivinha.html
File metadata and controls
98 lines (89 loc) · 2.03 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<title>Adivinha o Número</title>
<style>
body{
font: Tahoma;
align-items: center;
background-color: darkblue;
}
.titulo{
text-align: center;
color: whitesmoke;
}
.centro{
text-align: center;
margin: auto;
padding: 25px;
min-height: 300px;
height: auto;
width: 500px;
background-color: lightblue;
border-radius: 25px;
}
.resetar{
text-align: center;
width: 85px;
height: 25px;
border-radius: 20px;
font-weight: 300;
position: absolute;
bottom: 33%;
left: 45%;
}
.resetar:hover{
background-color: darkgray;
transition: 1.5s;
}
.botao{
text-align: center;
width: 85px;
height: 25px;
border-radius: 20px;
font-weight: 300;
}
.botao:hover{
background-color: darkgray;
transition: 1.5s
}
.texto{
text-align: center;
font-size: large;
}
</style>
</head>
<body>
<header class="titulo">
<h1>Adivinha o Número</h1>
</header>
<form>
<div class="centro">
<h3>Chute um número de 1 a 10:</h3>
<input placeholder="Digite aqui o seu número" class="numero">
<input type="submit" value="Chute!" class="btn" onclick="chute()">
<p class="texto"></p>
<button class="resetar" onclick="resetar()">Resetar</button>
</div>
</form>
<script>
function pulaLinha(){
document.write("<br><br>");
}
function mostra(frase){
document.write(frase);
pulaLinha();
}
function sorteia(n){
return Math.round(Math.random() * n);
}
var numeroPensado = sorteia(10);
console.log(numeroPensado);
var chute = parseInt(prompt("Chute um número: "));
if(chute == numeroPensado){
mostra("Você acertou!!");
} else{
mostra("Você errou!!! O número na verdade era o " + numeroPensado);
}
</script>