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