-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (21 loc) · 826 Bytes
/
app.js
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
//O principal objetivo deste desafio é fortalecer suas habilidades em lógica de programação. Aqui você deverá desenvolver a lógica para resolver o problema.
let inputName = document.querySelector("#amigo"); // swlecionando input
let Nome = [];
const Lista = document.querySelector("#listaAmigos");
const ResultadoSorteio = document.querySelector("#resultado");
function adicionarAmigo() {
let novoAmigo = inputName.value;
if (novoAmigo == "") {
alert("erro nome incompleto/incorreto");
}
Nome.push(novoAmigo);
console.log(Nome);
inputName.value = "";
Lista.innerHTML += `${novoAmigo} <br>`;
inputName.focus();
}
function sortearAmigo() {
let SorteioAmigo = Math.floor(Math.random()*Nome.length);
const NomeAleatorio = Nome[SorteioAmigo];
ResultadoSorteio.innerHTML = NomeAleatorio;
}