-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjogoLoteria.html
50 lines (39 loc) · 1.62 KB
/
jogoLoteria.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
44
45
46
47
48
49
50
<meta charset="utf-8">
<html>
<body>
Escolha um numero de 0 a 60 <input type='text' id='numero' autofocus/>
<input type='submit' onclick="guardarNumero()" value='guardar' id='guardar'/>
<input type='submit' onclick="adivinhaNumero()" value='verifique' id='adivinhar'/>
</body>
</html>
<script>
var numeroAleatorio = selecionaNumeroAleatorio(6);
console.log(numeroAleatorio);
var numeros = document.getElementById('numero').value;
var guardarNumeroVetor
function selecionaNumeroAleatorio(loop){
var vetor = new Array();
for(i = 0;i < loop; i++){
vetor[i] = Math.round(Math.random() * 60);
}
return vetor;
}
function guardarNumero(){
var numeroDigitado = document.getElementById('numero').value
guardarNumeroVetor = numeroDigitado.split(",");
for(i = 0; i < guardarNumeroVetor.length; i++){
guardarNumeroVetor[i] = parseInt(guardarNumeroVetor[i]);
}
console.log(guardarNumeroVetor);
}
function adivinhaNumero(){
for(i = 0; i < numeroAleatorio.length; i++){
for(j=0; j < guardarNumeroVetor.length;j++){
if(numeroAleatorio[i]==guardarNumeroVetor[j]){
alert("Você acertou " + numeroAleatorio[i]);
} else {
}
}
}
}
</script>