Skip to content

Instantly share code, notes, and snippets.

@KonradLinkowski
Created November 16, 2022 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KonradLinkowski/5eaf0fde26a4ee961a3ed9774de5f186 to your computer and use it in GitHub Desktop.
Save KonradLinkowski/5eaf0fde26a4ee961a3ed9774de5f186 to your computer and use it in GitHub Desktop.
function calcula(op) {
const operations = {
'+': (a, b) => a + b,
'-': (a, b) => a - b,
'*': (a, b) => a * b,
'/': (a, b) => a / b,
}
const operation = operations[op]
const n1 = document.getElementById("n1").value;
const n2 = document.getElementById("n2").value;
document.getElementById('ex13').value = operation(n1, n2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment