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;
case "NAND": return !(firstValue && secondValue);
default: return false
}
}
// No modificar: necesario para evaluar el resultado.
export { logicGate };0respuestas