Created
February 16, 2022 22:54
-
-
Save joelibaceta/ea5a617ff9bd00b1bd8b0d1946c1bb67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<form> | |
<p> | |
Ingrese numero 1: | |
<input id="n1" type="text" /> | |
</p> | |
<p> | |
Ingrese numero 2: | |
<input id="n2" type="text" /> | |
</p> | |
<p> El resultado es: <span id="resultado"></span> </p> | |
</form> | |
<button onclick="sumar()"> Sumar </button> | |
<button onclick="restar()"> Restar </button> | |
<script src="script.js" ></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n1 = document.getElementById("n1"); | |
var n2 = document.getElementById("n2"); | |
var resultado = document.getElementById("resultado"); | |
function sumar(){ | |
var suma = parseInt(n1.value) + parseInt(n2.value); | |
resultado.innerText = suma; | |
} | |
function restar() { | |
var suma = parseInt(n1.value) - parseInt(n2.value); | |
resultado.innerText = suma; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment