pero este código funciona solo las tres variables son verdaderas, sugiera que para otras condiciones no funciona.
Me gustaría saber cómo se ejecutan todas las condiciones siguientes.
//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; } } }fe:
var arr = []; if (A) arr.push("A+ content"); if (B) arr.push("RTA"); if (C) arr.push("Sectional configurator"); return arr.join(", ");Bien, aquí hay un ejemplo:
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>