forked from Dayvd-G/2not-2020-2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprova2.html
148 lines (121 loc) · 3.45 KB
/
prova2.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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Acumulador</title>
<script>
// 'use strict' impede que variáveis sejam declaradas
// sem o uso de let, var ou const
// Inicializar variáveis diretamente é má prática de
// programação
'use strict'
</script>
<style>
* {
font-family: 'Candara', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
html,
body {
position: absolute;
height: 100%;
width: 100%;
margin: 0;
font-size: 12pt;
line-height: 18pt;
color: #444;
}
body {
background-color: indigo;
background-image: linear-gradient(slateblue 50%, indigo);
background-repeat: no-repeat;
padding: 0;
}
body>div {
background: whitesmoke;
margin: 3%;
padding: 25px;
border-radius: 20px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
justify-content: space-around;
}
h1 {
font-size: 2rem;
text-align: center;
color: indigo;
text-shadow: 2px 2px 2px rgba(75, 0, 130, 0.5);
}
div>div {
padding: 10px;
width: 70%;
max-width: 90%;
min-width: 250px;
margin: 1% auto;
text-align: center;
}
div label {
display: block;
}
button {
font-size: 12pt;
padding: 8px;
border-radius: 8px;
color: white;
background-color: indigo;
}
p {
display: inline-block;
width: 30%;
margin: 0;
}
p span {
font-weight: bold;
color: indigo;
}
div div:last-of-type {
background-color: lavender;
border-radius: 12px;
}
</style>
</head>
<body>
<div>
<h1>Acumulador</h1>
<div>
<label>Informe um número</label>
<input id="num" type="number">
</div>
<div>
<button id="acumular">Acumular!</button>
</div>
<div>
<p>Quantidade: <span id="quant">0</span></p>
<p>Média: <span id="media">0</span></p>
<p>Soma: <span id="soma">0</span></p>
</div>
</div>
<script>
/* PASSO 1: captura de elementos HTML */
const elPrimeiroNumero = document.getElementById('num')
const elAcumular = document.querySelector('#acumular')
const elQtd = document.getElementById('quant')
const elMedia = document.getElementById('media')
const elSoma = document.getElementById('soma')
//Declarando um vetor vazio
let vetor1 = []
//Função com um parametro
function soma(vetor1) {
let soma = 0
for(let i = num; i > 1; i++ ){
fat += i
}
return fat
}
// Limpar o campo
elPrimeiroNumero.value = ""
elPrimeiroNumero.focus()
</script>
</body>
</html>