Solución
solution.tsTypeScript
function logicGate(firstValue: boolean, secondValue: boolean, gate: "AND" | "OR" | "XOR" | "NAND"): boolean {
if (gate == "AND"){ return firstValue && secondValue;}
else if (gate == "OR"){return firstValue || secondValue;}
else if (gate == "XOR"){
if (firstValue == secondValue) return false;
else return true;
}
else if (gate == "NAND") return !(firstValue && secondValue);
return;
}
// No modificar: necesario para evaluar el resultado.
export { logicGate };0respuestas