Olá, estou tendo um erro no meu codigo. Alguem poderia me ajudar onde errei por favor?
[let amigosSorteados = [];
function adicionar() {
let nomeAmigo = document.getElementById('nome-amigo');
let lista = document.getElementById('lista-amigos');
amigosSorteados.push(nomeAmigo.value);
if (lista.textContent == '') {
lista.textContent = nomeAmigo.value;
} else {
lista.textContent = lista.textContent + ', ' + nomeAmigo.value;
}
nomeAmigo.value = '';
}
function sortear() {
embaralhar(amigosSorteados);
let sorteio = document.getElementById('lista-sorteio');
for (let i = 0; i < amigosSorteados.length; i++) {
if (i == amigos.length - 1) {
sorteio.innerHTML = sorteio.innerHTML + amigosSorteados[i] +' --> ' +amigosSorteados[0] + '
';
}else {
sorteio.innerHTML = sorteio.innerHTML + amigosSorteados[i] +' --> ' +amigosSorteados[i + 1] + '
';
}
}
}
function embaralhar(lista) {
for (let indice = lista.length; indice; indice--) {
const indiceAleatorio = Math.floor(Math.random() * indice);
[lista[indice - 1], lista[indiceAleatorio]] = [lista[indiceAleatorio], lista[indice - 1]];
}
}
function reiniciar() {
}]()