Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

com uma ajudinha mas consegui!

const robo = document.querySelector("#robotron");

const robos = [
    "/img/Robotron 2000 - Rosa/Robotron 2000 - Rosa.png",
    "/img/Robotron 2000 - Azul/Robotron 2000 - Azul.png",
    "/img/Robotron 2000 - Amarelo/Robotron 2000 - Amarelo.png",
    "/img/Robotron 2000 - Preto/Robotron 2000 - Preto.png",
    "/img/Robotron 2000 - Vermelho/Robotron 2000 - Vermelho.png",
    "/img/Robotron 2000 - Branco/Robotron 2000 - Branco.png"
]

robo.addEventListener('click', (elemento) => {
    elemento.target.src = trocaRobo();

});

var indice = 0;
function trocaRobo () { 
    const imagemSrc = robos[indice];
    indice++;

    if(indice >= robos.length){
        indice = 0;
    }
    return imagemSrc; 
}
1 resposta
solução!

Oi Jonas, tudo bem?

Isso aí! Parabéns por praticar.

Muito obrigada por compartilhar com a gente o seu código. :D

Um abraço e bons estudos.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software