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

87
Visualizações
I have 3 variables which will return true or false values and i need to compare those 3 variables i need to return values i have tried below code

but this code is working only all the three variables are true please suggest for other conditions it is not working.

i would like to know how all the below condition executes.

  //this is the function//
 function()
    {
      if({{var - customJS - page_type_lookup}} === 'product' || {{var - aev - element click text}} === 'Quick View') {
        var A = document.querySelector('#pdpMain > div.product-aplus-content.clearfix > div.content-desktop > div.content-container > img').getAttribute('alt').includes('A Plus Content');// variable 1
     
        var B = document.querySelector("#rta-badge > div.rta-assembly-content > div.rta-left-section > span").innerText.includes('Assembly required');// variable 2
    
        var C = document.querySelector('#product-content > div.product-variations.clearfix > div.attribute.variant-dropdown > div.attribute-values-section > div.label.va-navSectionalOrientation').innerText.includes('Sectional Orientation');// variable 3
        
    //comparison    // if(A === true && B === true && C === true)
        {
          return 'A+ Content, RTA, Sectional configurator';
        }
        else if(A === true && B === true && C !== true)
        {
          return 'A+ Content, RTA';
        }
       else if(A === true && B !== true && C === true)
       {
         return 'A+ Content, Sectional configurator';
       }
        else if (A !== true && B === true && C === true)
        {
          return 'RTA, Sectional configurator';
        }
        else if(A === true && B !== true && C !== true)
        {
          return 'A+ content';
         }
        else if(A !== true && B === true && C !== true)
        {
          return 'RTA';
        }
        else if(A !== true && B !== true && C === true)
        {
          return 'Sectional configurator';
        }
        else if(A !== true && B !== true && C !== true)
        {
          return;
        }
      }

}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

f.e.:

var arr = [];
if (A) arr.push("A+ content");
if (B) arr.push("RTA");
if (C) arr.push("Sectional configurator");

return arr.join(", ");

Ok, here is an example:

function go () {
  var arr = [];
  if (document.getElementById("A").checked) arr.push("A+ Content");
  if (document.getElementById("B").checked) arr.push("RTA");
  if (document.getElementById("C").checked) arr.push("Sectional configurator");
  document.getElementById("ret").value = arr.join(", ");
}
<input type="checkbox" id="A">variable A</input><br>
<input type="checkbox" id="B">variable B</input><br>
<input type="checkbox" id="C">variable C</input><br>
<button onclick="javascript:go();">Go!</button><br>
<textarea id="ret"></textarea>

about 4 years ago · Juan Pablo Isaza Relatório
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