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