Skip to content

Commit

Permalink
deploy: e09d63f
Browse files Browse the repository at this point in the history
  • Loading branch information
digimbyte committed Jul 3, 2024
1 parent 73fa67c commit d0e4249
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions assets/tools/calculator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Simple Calculator

This is a simple calculator embedded in a markdown file.

<div id="calculator">
<input type="text" id="result" disabled>
<br>
<button onclick="clearResult()">C</button>
<button onclick="appendNumber(1)">1</button>
<button onclick="appendNumber(2)">2</button>
<button onclick="appendNumber(3)">3</button>
<button onclick="appendNumber('+')">+</button>
<br>
<button onclick="appendNumber(4)">4</button>
<button onclick="appendNumber(5)">5</button>
<button onclick="appendNumber(6)">6</button>
<button onclick="appendNumber('-')">-</button>
<br>
<button onclick="appendNumber(7)">7</button>
<button onclick="appendNumber(8)">8</button>
<button onclick="appendNumber(9)">9</button>
<button onclick="appendNumber('*')">*</button>
<br>
<button onclick="appendNumber(0)">0</button>
<button onclick="calculateResult()">=</button>
<button onclick="appendNumber('/')">/</button>
</div>

<script>
function appendNumber(number) {
document.getElementById('result').value += number;
}

function clearResult() {
document.getElementById('result').value = '';
}

function calculateResult() {
var result = eval(document.getElementById('result').value);
document.getElementById('result').value = result;
}
</script>

0 comments on commit d0e4249

Please sign in to comment.