-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaula04.01.html
More file actions
54 lines (38 loc) · 1.52 KB
/
aula04.01.html
File metadata and controls
54 lines (38 loc) · 1.52 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
<!doctype html>
<html>
<head>
<title>Logica de Programação Javascript</title>
<meta charset="utf-8">
</head>
<body>
<h1>Lógica de programação com Javascript</h1>
<button onclick="mostrarTabuada()">Criar Tabuada</button>
<button onclick="limparTabuada()">Limpar Tabuada</button>
<div id="output"></div>
<script>
function mostrarTabuada(){
//perguntar o numero para o usuario
var n = prompt('digite um numero');
limparTabuada();
//converter o numero
n = parseFloat(n);
//criar uma variavel que servira de indice
var i = 1;
//enquanto indice <= 1000
//concatena na variavel mensagem
while(i <= 1000){
mensagem += n + ' x '+ i +' = '+ (n*i) +' <br>';
i++;
}
output.innerHTML = mensagem;
//mostra mensagem no output
}
function limparTabuada(){
mensagem = '';
output.innerHTML = mensagem;
}
var output = document.querySelector('#output');
var mensagem = '';
</script>
</body>
</html>