Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions calculator.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<!DOCTYPE html><html><head>
<title>Calculator</title><meta charset="utf-8">
<script type="text/javascript">

function square() {
var num = document.getElementById("n1");
num.value = num.value * num.value;
}
</script>
</head>
<body>
Number:
<input type="text" id="n1"><p>

<button onclick="square()"> x<sup>2</sup> </button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title><meta charset="utf-8">
<script type="text/javascript">
function inverse() {
var num = document.getElementById("n1");
num.value = 1/num.value;
}
function square() {
var num = document.getElementById("n1");
num.value = num.value * num.value;
}
</script>
</head>
<body>
<h1>Víctor Loureiro Sancho</h1>
Number:
<input type="text" id="n1"><p>
<button onclick="inverse()"> 1/x </button>
<button onclick="square()"> x<sup>2</sup> </button>
</body>