From 28766b24a98d6cdf28116b307cb6679eff4e08a5 Mon Sep 17 00:00:00 2001 From: Sir-Aguiar <80969713+Sir-Aguiar@users.noreply.github.com> Date: Fri, 8 Oct 2021 10:13:42 -0300 Subject: [PATCH] =?UTF-8?q?Agora=20o=20elemento=20=C3=A9=20devidamente=20c?= =?UTF-8?q?alculado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JogosEliminatorios/app.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/JogosEliminatorios/app.js b/JogosEliminatorios/app.js index 04fa8fc..dbeaf80 100644 --- a/JogosEliminatorios/app.js +++ b/JogosEliminatorios/app.js @@ -48,19 +48,18 @@ btnListar.addEventListener('click', listarClube); function mostarTabela() { let jogos = '' - let ultimoClube = todosClubes[todosClubes.length - 1]; + let ultimoElemento = (todosClubes.length -1) - if ((todosClubes.length % 2) !== 0 || todosClubes.length == 0) { + if ((todosClubes.length % 2) != 0 || todosClubes.length == 0) { alert('Adicione mais um clube para poder montar a tabela de jogos !'); inputClube.focus(); return; } - - for (let index = 0; index < (todosClubes.length - 1) / 2; index++) { - jogos += `${todosClubes[index]} x ${ultimoClube - index}\n`; + for (let index = 0; index < (ultimoElemento)/2; index++){ + jogos +=(`${todosClubes[index]} x ${todosClubes[(ultimoElemento)-index]}\n`) } outLista.textContent = jogos; } -btnTabela.addEventListener('click', mostarTabela); \ No newline at end of file +btnTabela.addEventListener('click', mostarTabela);