0
respostas

Desafio Alugames completo

let jogosAlugados = 0;
function contarEExibirJogosAlugados(){
    console.log(`total de jogos alugados: ${jogosAlugados} `);
}

function alterarStatus(id) {
let gameclicado = document.getElementById(`game-${id}`);
let imagem = gameclicado.querySelector('.dashboard__item__img');
let botao = gameclicado.querySelector('.dashboard__item__button');
let nomeJogo = gameclicado.querySelector('.dashboard__item__name');

if (imagem.classList.contains('dashboard__item__img--rented')) {
    imagem.classList.remove('dashboard__item__img--rented');
    botao.classList.remove('dashboard__item__button--return');

    botao.textContent = 'alugar';
    jogosAlugados --; 

} else {
    imagem.classList.add('dashboard__item__img--rented');
    botao.classList.add('dashboard__item__button--return');

      botao.textContent = 'devolver';
      jogosAlugados ++; 
}
contarEExibirJogosAlugados();


}

document.addEventListener('DOMContentLoaded', function() {
    jogosAlugados = document.querySelectorAll('.dashboard__item__img--rented').length;
    contarEExibirJogosAlugados();
});

function ordenarNumeros(a, b, c) {
    const numerosOrdenados = [a, b, c].sort((x, y) => x - y);
    console.log(`Números ordenados: ${numerosOrdenados.join(', ')}`);
}