forked from Dayvd-G/2not-2020-2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path07-for.html
53 lines (42 loc) · 1.19 KB
/
07-for.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
//"use scrict" impede que variaveis sejam declaradas seo uso do let, var ou const
//Iniciar variáveis diretamente é uma má pratica de programação
"use scrict"
/*
Caracteristicas do loop for
1) Local do teste: no início
2) Garantia de execução: 0 (zero)
3) Número de repetições: determinado ou determinável
*/
//Escrever os numeros de 1 a 10
/*Três partes do for, separadas por:
1) Inicialização
2) Condição
3) Incremento
*/
for(let i = 1; i <= 10; i = i + 1) {
document.write(i + "<br>")
}
//Traço HTML
document.write('<hr>')
// Escrever os numeros de um a dez, saltando de dois em dois
for(let i = 1; i <= 10; i += 2){
document.write(i + '<br>')
}
//Traço HTML
document.write('<hr>')
//Escrever os números de 10 a 1, em ordem reversa
for(let i = 10; i >= 1; i --){
document.write(i + '<br>')
}
</script>
</head>
<body>
</body>
</html>