-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex010.htm
More file actions
34 lines (28 loc) · 951 Bytes
/
Copy pathex010.htm
File metadata and controls
34 lines (28 loc) · 951 Bytes
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
<!DOCTYPE html>
<html lang="pr-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Condicoes aninhadas</title>
</head>
<body>
<h3>Qual a sua idade? </h3>
<input type="number" name="idadde" id="idade">
<input type="submit" value="number" onclick="enviar()">
<br>
<div id="answer"></div>
<script>
function enviar() {
const idade = document.querySelector('input#idade')
const answer = document.querySelector('div#answer')
const idadeNum = Number(idade.value)
if (idadeNum >= 18) {
answer.innerHTML = (`Você tem ${idadeNum} anos, já é maior de idade.`)
} else {
answer.innerHTML = (`Você tem ${idadeNum} anos, você é menor de idade.`)
}
}
</script>
</body>
</html>