1
0
mirror of https://github.com/balkian/my_calculator_2.git synced 2024-11-22 07:22:29 +00:00

x^2 button

This commit is contained in:
J. Fernando Sánchez 2019-01-31 11:38:19 +01:00
parent 82165b0979
commit b95b431fc2

View File

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