🎯 Sorteador de Comentários

Cole os comentários (1 por linha)

.container-sorteio { background: #111; padding: 30px; border-radius: 15px; text-align: center; color: #fff; max-width: 500px; margin: auto; } textarea, input { width: 100%; margin: 10px 0; padding: 10px; border-radius: 8px; border: none; } button { width: 100%; padding: 12px; background: #ff3c3c; color: #fff; border: none; border-radius: 8px; cursor: pointer; } #resultado { margin-top: 20px; font-size: 18px; } document.addEventListener("DOMContentLoaded", function () { document.getElementById("btnSortear").addEventListener("click", function () { let texto = document.getElementById("comments").value.trim(); let qtd = parseInt(document.getElementById("qtd").value); if (!texto) { alert("Cole os comentários!"); return; } let lista = texto.split(/\n/).map(c => c.trim()).filter(c => c); if (qtd > lista.length) { alert("Mais ganhadores do que comentários!"); return; } let sorteados = []; while (sorteados.length < qtd) { let rand = Math.floor(Math.random() * lista.length); let escolhido = lista[rand]; if (!sorteados.includes(escolhido)) { sorteados.push(escolhido); } } document.getElementById("resultado").innerHTML = "🎉 Ganhador(es):
" + sorteados.join("
"); }); });