Solución
solution.tsTypeScript
function logicGate(firstValue: boolean, secondValue: boolean, gate: "AND" | "OR" | "XOR" | "NAND"): boolean {
const gateMap: Record<string,boolean> = {
AND: firstValue && secondValue,
OR: firstValue || secondValue,
XOR: firstValue !== secondValue,
NAND: !(firstValue && secondValue),
}
return gateMap[gate];
}
// No modificar: necesario para evaluar el resultado.
export { logicGate }0respuestas