Created
January 1, 2021 19:27
-
-
Save Ademking/77253f5cfc01d1736ed0fb138e339ad7 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<input id="n1" type="number" /> | |
<select id="operation"> | |
<option value="+">+</option> | |
<option value="-">-</option> | |
<option value="*">x</option> | |
<option value="/">/</option> | |
</select> | |
<input id="n2" type="number" /> | |
<button onclick="calculer()" id="egal">Calculer</button> | |
<h1 id="resultat"></h1> | |
<script> | |
function calculer() { | |
let n1 = parseInt(document.getElementById("n1").value); | |
let n2 = parseInt(document.getElementById("n2").value); | |
let signe = document.getElementById('operation').value; | |
console.log(signe) | |
let resulat; | |
switch (signe) { | |
case "+": | |
resulat = n1 + n2; | |
break; | |
case "-": | |
resulat = n1 - n2; | |
break; | |
case "*": | |
resulat = n1 * n2; | |
break; | |
case "/": | |
resulat = n1 / n2; | |
break; | |
} | |
document.getElementById("resultat").innerHTML = resulat; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment