0
How can I set the second "&& bonus2" parameter as optional ?
I want the ways to run if: (bonus1 && bonus2 == true) or (bonus1 == true)
It needs to be a parameter that if I put it in the accepted function and rotate, if I do not put I remain normal, it is not a default value.
function offersFixed(bonus1, bonus2, textValue ){
if (bonus1 && bonus2 == true ){
var valide = document.getElementById("valideorNot");
valide.setAttribute("class", "invalidPass")
valide.textContent = "Oferta Inválida";
var textId = document.getElementById("validateResult");
var createText = document.createElement("h3");
createText.textContent = textValue;
textId.appendChild(createText);
}
}
If bonus2 is optional, it makes no sense
(bonus1 && bonus2 == true)
– Sam
If bonus2 is optional, why check it? Unless inside the if it will influence something. Then you should make another if inside the if.
– Sam
Shouldn’t be an OR?
if (bonus1 === true || bonus2)
? Will only check bonus2 if bonus1 is not true.– Leite