Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
Function parameter returning "undefined"

I'm hoping someone can tell me what I'm doing wrong here. When trying to log the value of artistBox in the hideProductCard function, it's returning 'undefined'. However, when logging the value of artistBox in the addArtistSelection function it returns with the correct value. Why is this happening? Both functions, as seen in the 'if/else if conditionals' are taking the same parameter and it is being passed along to both functions, but only one is working.

// Adding Artist Selection
let artistCheckBoxes = document.querySelectorAll('.artist-filter-input');
let artistProductCards = document.querySelectorAll('.store-card');

artistCheckBoxes.forEach((artistBox) => {
    artistBox.addEventListener('click', () => {
        if (artistBox.checked === true) {
            addArtistSelection(artistBox);
            hideProductCard(artistBox);
        } else if (artistBox.checked === false) {
            document.getElementById(`${artistBox.value}-selection`).remove();
        }
    });
});

let addArtistSelection = (artistBox) => {
    let artistSelectionContainer = document.querySelector('.artist-selection-container');
    let artistSelection = document.createElement('p');
    artistSelection.classList = 'filter-selection artist-selection';
    artistSelection.id = `${artistBox.value}-selection`;
    artistSelection.innerHTML = `
                    ${artistBox.value}
                `;
    artistSelectionContainer.appendChild(artistSelection);
};

let hideProductCard = (artistBox) => {
    artistProductCards.forEach((productCard) => {
        console.log(productCard.querySelector('.card-title').innerText);
        console.log(artistBox.value);
    });
};

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda