Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercícios 1 e 2 de Javascript resolvidos #190

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions aulas-javascript/exercicios/aula1/exercicio_javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function checarSePodeDirigir(idade){

if (idade >= 18) {
alert('Já pode dirigir!');
} else {
alert('Ainda não pode dirigir!');
}
}

checarSePodeDirigir(16);
13 changes: 13 additions & 0 deletions aulas-javascript/exercicios/aula1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="pt-br">

<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Exemplo de JavaScript Externo</title>
<script src="exercicio_javascript.js" defer></script>
</head>

<body></body>

</html>
29 changes: 29 additions & 0 deletions aulas-javascript/exercicios/aula2/exercicio_javascript2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function saoDiferentes(){
let input1 = document.querySelector('#input1').value;
let input2 = document.querySelector('#input2').value;

if (input1 !== input2){
let div = document.createElement('div');
div.innerText = 'Os valores são diferentes!';
document.body.append(div);
div.style.color = 'green';
div.style.marginTop = '30px';
div.style.fontSize = '24px';
} else{
let div = document.createElement('div');
div.innerText = 'Não são diferentes!';
document.body.append(div);
div.style.color = 'red';
div.style.marginTop = '30px';
div.style.fontSize = '24px';
}
}

function resetar(){
document.getElementById('input1').value = '';
document.getElementById('input2').value = '';
document.getElementsByTagName('div').remove();
}

document.getElementById('botaoChecar').onclick = saoDiferentes;
document.getElementById('botaoResetar').onclick = resetar;
31 changes: 31 additions & 0 deletions aulas-javascript/exercicios/aula2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Exemplo de JavaScript Externo</title>
<link rel="stylesheet" href="style.css"/>
<script src="exercicio_javascript2.js" defer></script>
</head>
<body>
<header>
<h1>Formulário - Comparar Números.</h1>
</header>
<form>
<div>
<label for="number1" >
<b>Número 1:</b>
<input id="input1" type="number" placeholder="Digite Aqui" style="text-align:center"/>
</label>
</div>
<div>
<label for="number2">
<b>Número 2:</b>
<input id="input2" type="number" placeholder="Digite Aqui" style="text-align:center"/>
</label>
</div>
<button type="button" style="text-align:center" id="botaoChecar" onclick="saoDiferentes()">Checar se são diferentes</button>
<button type="button" style="text-align:center" id="botaoResetar" onclick="resetar()">RESET</button>
</form>
</body>
</html>
19 changes: 19 additions & 0 deletions aulas-javascript/exercicios/aula2/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
display: flex;
flex-direction: column;
flex: 1;
align-items: center;
box-sizing: border-box;
justify-content: center;
}

input { /*-aplica por padrão a margin em todas tags input-*/
border:none;
background:#fafafa;
color:000;
margin: 10px;
}

button {
border: none;
}