x^2 button

ops
J. Fernando Sánchez 5 years ago
parent 82165b0979
commit b95b431fc2

@ -2,8 +2,12 @@
<title>Calculator</title><meta charset="utf-8">
<script type="text/javascript">
function cube() {
var num = document.getElementById("n1");
num.value = Math.pow(num.value, 3);
var num = document.getElementById("n1");
num.value = Math.pow(num.value, 3);
}
function square() {
var num = document.getElementById("n1");
num.value = Math.pow(num.value, 2);
}
</script>
</head>
@ -12,5 +16,6 @@ num.value = Math.pow(num.value, 3);
Number:
<input type="text" id="n1"><p>
<button onclick="cube()"> x^3 </button>
<button onclick="square()"> x^2 </button>
</body>
</html>

Loading…
Cancel
Save