Solución

JL@juanluisabreu_4c541ef6
·4/4/2026TypeScript
solution.tsTypeScript
function logicGate(firstValue: boolean, secondValue: boolean, gate: "AND" | "OR" | "XOR" | "NAND"): boolean {
  let evaluar = gate == "AND"? firstValue + " && " + secondValue:
                gate == "OR"? firstValue + " || " + secondValue:
                gate == "XOR"? "!(" + firstValue + " || " + secondValue + ")":
                               "!(" + firstValue + " && " + secondValue + ")";

  return eval(evaluar);
}

// No modificar: necesario para evaluar el resultado.
export { logicGate };
0respuestas
Respuestas
0

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.
Markdown